diff --git a/ruoyi-train/src/main/java/com/ruoyi/course/controller/TrainCourseCategoryController.java b/ruoyi-train/src/main/java/com/ruoyi/course/controller/TrainCourseCategoryController.java new file mode 100644 index 000000000..c8245d18f --- /dev/null +++ b/ruoyi-train/src/main/java/com/ruoyi/course/controller/TrainCourseCategoryController.java @@ -0,0 +1,152 @@ +package com.ruoyi.course.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.base.AjaxResult; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.course.domain.TrainCourseCategory; +import com.ruoyi.course.service.ITrainCourseCategoryService; +import com.ruoyi.framework.web.base.BaseController; +import com.ruoyi.framework.web.util.ShiroUtils; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; +import org.springframework.web.bind.annotation.*; + +import java.util.List; +import java.util.Map; + +/** + * 课程分类管理 + * + * @author ruoyi + */ +@Controller +@RequestMapping("/train/course/category") +public class TrainCourseCategoryController extends BaseController +{ + private String prefix = "course/category"; + + @Autowired + private ITrainCourseCategoryService trainCourseCategoryService; + + @RequiresPermissions("train:course:category:view") + @GetMapping() + public String dept() + { + return prefix + "/dept"; + } + + @RequiresPermissions("train:course:category:list") + @GetMapping("/list") + @ResponseBody + public List list(TrainCourseCategory dept) + { + List deptList = trainCourseCategoryService.selectDeptList(dept); + return deptList; + } + + /** + * 新增课程分类 + */ + @GetMapping("/add/{parentId}") + public String add(@PathVariable("parentId") Long parentId, ModelMap mmap) + { + mmap.put("dept", trainCourseCategoryService.selectDeptById(parentId)); + return prefix + "/add"; + } + + /** + * 新增保存课程分类 + */ + @Log(title = "课程分类管理", businessType = BusinessType.INSERT) + @RequiresPermissions("train:course:category:add") + @PostMapping("/add") + @ResponseBody + public AjaxResult addSave(TrainCourseCategory dept) + { + dept.setCreateBy(ShiroUtils.getLoginName()); + return toAjax(trainCourseCategoryService.insertDept(dept)); + } + + /** + * 修改 + */ + @GetMapping("/edit/{deptId}") + public String edit(@PathVariable("deptId") Long deptId, ModelMap mmap) + { + TrainCourseCategory dept = trainCourseCategoryService.selectDeptById(deptId); + if (StringUtils.isNotNull(dept) && 100L == deptId) + { + dept.setParentName("无"); + } + mmap.put("dept", dept); + return prefix + "/edit"; + } + + /** + * 保存 + */ + @Log(title = "课程分类管理", businessType = BusinessType.UPDATE) + @RequiresPermissions("train:course:category:edit") + @PostMapping("/edit") + @ResponseBody + public AjaxResult editSave(TrainCourseCategory dept) + { + dept.setUpdateBy(ShiroUtils.getLoginName()); + return toAjax(trainCourseCategoryService.updateDept(dept)); + } + + /** + * 删除 + */ + @Log(title = "课程分类管理", businessType = BusinessType.DELETE) + @RequiresPermissions("train:course:category:remove") + @PostMapping("/remove/{deptId}") + @ResponseBody + public AjaxResult remove(@PathVariable("deptId") Long deptId) + { + if (trainCourseCategoryService.selectDeptCount(deptId) > 0) + { + return error(1, "存在下级课程分类,不允许删除"); + } + if (trainCourseCategoryService.checkDeptExistUser(deptId)) + { + return error(1, "课程分类存在用户,不允许删除"); + } + return toAjax(trainCourseCategoryService.deleteDeptById(deptId)); + } + + /** + * 校验课程分类名称 + */ + @PostMapping("/checkDeptNameUnique") + @ResponseBody + public String checkDeptNameUnique(TrainCourseCategory dept) + { + return trainCourseCategoryService.checkDeptNameUnique(dept); + } + + /** + * 选择课程分类树 + */ + @GetMapping("/selectDeptTree/{deptId}") + public String selectDeptTree(@PathVariable("deptId") Long deptId, ModelMap mmap) + { + mmap.put("dept", trainCourseCategoryService.selectDeptById(deptId)); + return prefix + "/tree"; + } + + /** + * 加载课程分类列表树 + */ + @GetMapping("/treeData") + @ResponseBody + public List> treeData() + { + List> tree = trainCourseCategoryService.selectDeptTree(); + return tree; + } + +} diff --git a/ruoyi-train/src/main/java/com/ruoyi/course/domain/TrainCourseCategory.java b/ruoyi-train/src/main/java/com/ruoyi/course/domain/TrainCourseCategory.java new file mode 100644 index 000000000..6f656ccdf --- /dev/null +++ b/ruoyi-train/src/main/java/com/ruoyi/course/domain/TrainCourseCategory.java @@ -0,0 +1,132 @@ +package com.ruoyi.course.domain; + +import com.ruoyi.common.base.BaseEntity; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +import javax.persistence.Id; + +/** + * 课程分类表 sys_dept + * + * @author ruoyi + */ +public class TrainCourseCategory extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 分类ID */ + @Id + private Long id; + /** + * 课程分类 + */ + private Long deptId; + /** 父课程分类ID */ + private Long parentId; + + /** 祖级列表 */ + private String parentIds; + + /** 课程分类名称 */ + private String name; + + /** 显示顺序 */ + private String orderNum; + + /** 删除标志(0代表存在 2代表删除) */ + private String delFlag; + + /** 父课程分类名称 */ + private String parentName; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Long getDeptId() { + return deptId; + } + + public void setDeptId(Long deptId) { + this.deptId = deptId; + } + + public Long getParentId() + { + return parentId; + } + + public void setParentId(Long parentId) + { + this.parentId = parentId; + } + + public String getParentIds() { + return parentIds; + } + + public void setParentIds(String parentIds) { + this.parentIds = parentIds; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getOrderNum() + { + return orderNum; + } + + public void setOrderNum(String orderNum) + { + this.orderNum = orderNum; + } + + + public String getDelFlag() + { + return delFlag; + } + + public void setDelFlag(String delFlag) + { + this.delFlag = delFlag; + } + + public String getParentName() + { + return parentName; + } + + public void setParentName(String parentName) + { + this.parentName = parentName; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("deptId", getDeptId()) + .append("parentId", getParentId()) + .append("ancestors", getParentIds()) + .append("deptName", getName()) + .append("orderNum", getOrderNum()) + .append("delFlag", getDelFlag()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .toString(); + } +} diff --git a/ruoyi-train/src/main/java/com/ruoyi/course/mapper/TrainCourseCategoryMapper.java b/ruoyi-train/src/main/java/com/ruoyi/course/mapper/TrainCourseCategoryMapper.java new file mode 100644 index 000000000..3b11911d7 --- /dev/null +++ b/ruoyi-train/src/main/java/com/ruoyi/course/mapper/TrainCourseCategoryMapper.java @@ -0,0 +1,96 @@ +package com.ruoyi.course.mapper; + +import com.ruoyi.course.domain.TrainCourseCategory; +import com.ruoyi.framework.web.base.MyMapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 课程分类管理 数据层 + * + * @author ruoyi + */ +public interface TrainCourseCategoryMapper extends MyMapper +{ + /** + * 查询课程分类人数 + * + * @param dept 课程分类信息 + * @return 结果 + */ + public int selectDeptCount(TrainCourseCategory dept); + + /** + * 查询课程分类是否存在用户 + * + * @param deptId 课程分类ID + * @return 结果 + */ + public int checkDeptExistUser(Long deptId); + + /** + * 查询课程分类管理数据 + * + * @param dept 课程分类信息 + * @return 课程分类信息集合 + */ + public List selectDeptList(TrainCourseCategory dept); + + /** + * 删除课程分类管理信息 + * + * @param deptId 课程分类ID + * @return 结果 + */ + public int deleteDeptById(Long deptId); + + /** + * 新增课程分类信息 + * + * @param dept 课程分类信息 + * @return 结果 + */ + public int insertDept(TrainCourseCategory dept); + + /** + * 修改课程分类信息 + * + * @param dept 课程分类信息 + * @return 结果 + */ + public int updateDept(TrainCourseCategory dept); + + /** + * 修改子元素关系 + * + * @param depts 子元素 + * @return 结果 + */ + public int updateDeptChildren(@Param("depts") List depts); + + /** + * 根据课程分类ID查询信息 + * + * @param deptId 课程分类ID + * @return 课程分类信息 + */ + public TrainCourseCategory selectDeptById(Long deptId); + + /** + * 校验课程分类名称是否唯一 + * + * @param deptName 课程分类名称 + * @param parentId 父课程分类ID + * @return 结果 + */ + public TrainCourseCategory checkDeptNameUnique(@Param("deptName") String deptName, @Param("parentId") Long parentId); + + /** + * 根据角色ID查询课程分类 + * + * @param roleId 角色ID + * @return 课程分类列表 + */ + public List selectRoleDeptTree(Long roleId); +} diff --git a/ruoyi-train/src/main/java/com/ruoyi/course/service/ITrainCourseCategoryService.java b/ruoyi-train/src/main/java/com/ruoyi/course/service/ITrainCourseCategoryService.java new file mode 100644 index 000000000..bdeaf77f7 --- /dev/null +++ b/ruoyi-train/src/main/java/com/ruoyi/course/service/ITrainCourseCategoryService.java @@ -0,0 +1,88 @@ +package com.ruoyi.course.service; + +import com.ruoyi.course.domain.TrainCourseCategory; +import com.ruoyi.framework.web.base.AbstractBaseService; + +import java.util.List; +import java.util.Map; + +/** + * 课程分类管理 服务层 + * + * @author ruoyi + */ +public interface ITrainCourseCategoryService extends AbstractBaseService +{ + /** + * 查询课程分类管理数据 + * + * @param dept 课程分类信息 + * @return 课程分类信息集合 + */ + public List selectDeptList(TrainCourseCategory dept); + + /** + * 查询课程分类管理树 + * + * @return 所有课程分类信息 + */ + public List> selectDeptTree(); + + + + /** + * 查询课程分类人数 + * + * @param parentId 父课程分类ID + * @return 结果 + */ + public int selectDeptCount(Long parentId); + + /** + * 查询课程分类是否存在用户 + * + * @param deptId 课程分类ID + * @return 结果 true 存在 false 不存在 + */ + public boolean checkDeptExistUser(Long deptId); + + /** + * 删除课程分类管理信息 + * + * @param deptId 课程分类ID + * @return 结果 + */ + public int deleteDeptById(Long deptId); + + /** + * 新增保存课程分类信息 + * + * @param dept 课程分类信息 + * @return 结果 + */ + public int insertDept(TrainCourseCategory dept); + + /** + * 修改保存课程分类信息 + * + * @param dept 课程分类信息 + * @return 结果 + */ + public int updateDept(TrainCourseCategory dept); + + /** + * 根据课程分类ID查询信息 + * + * @param deptId 课程分类ID + * @return 课程分类信息 + */ + public TrainCourseCategory selectDeptById(Long deptId); + + /** + * 校验课程分类名称是否唯一 + * + * @param dept 课程分类信息 + * @return 结果 + */ + public String checkDeptNameUnique(TrainCourseCategory dept); +} diff --git a/ruoyi-train/src/main/java/com/ruoyi/course/service/impl/TrainCourseCategoryServiceImpl.java b/ruoyi-train/src/main/java/com/ruoyi/course/service/impl/TrainCourseCategoryServiceImpl.java new file mode 100644 index 000000000..18375e04f --- /dev/null +++ b/ruoyi-train/src/main/java/com/ruoyi/course/service/impl/TrainCourseCategoryServiceImpl.java @@ -0,0 +1,192 @@ +package com.ruoyi.course.service.impl; + +import com.ruoyi.common.annotation.DataScope; +import com.ruoyi.common.constant.UserConstants; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.course.domain.TrainCourseCategory; +import com.ruoyi.course.mapper.TrainCourseCategoryMapper; +import com.ruoyi.course.service.ITrainCourseCategoryService; +import com.ruoyi.framework.web.base.AbstractBaseServiceImpl; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 课程分类管理 服务实现 + * + * @author ruoyi + */ +@Service +public class TrainCourseCategoryServiceImpl extends AbstractBaseServiceImpl implements ITrainCourseCategoryService { + + @Autowired + private TrainCourseCategoryMapper trainCourseCategoryMapper; + + /** + * 查询课程分类管理数据 + * + * @return 课程分类信息集合 + */ + @Override + @DataScope(tableAlias = "d") + public List selectDeptList(TrainCourseCategory dept) { + return trainCourseCategoryMapper.selectDeptList( dept ); + } + + /** + * 查询课程分类管理树 + * + * @return 所有课程分类信息 + */ + @Override + public List> selectDeptTree() { + List deptList = selectDeptList( new TrainCourseCategory() ); + List> trees = getTrees( deptList, false, null ); + return trees; + } + + + /** + * 对象转课程分类树 + * + * @param deptList 课程分类列表 + * @param isCheck 是否需要选中 + * @param roleDeptList 角色已存在菜单列表 + * @return + */ + public List> getTrees(List deptList, boolean isCheck, List roleDeptList) { + + List> trees = new ArrayList>(); + for (TrainCourseCategory dept : deptList) { + if (UserConstants.DEPT_NORMAL.equals( dept.getDelFlag() )) { + Map deptMap = new HashMap(); + deptMap.put( "id", dept.getId() ); + deptMap.put( "pId", dept.getParentId() ); + deptMap.put( "name", dept.getName() ); + deptMap.put( "title", dept.getName() ); + if (isCheck) { + deptMap.put( "checked", roleDeptList.contains( dept.getDeptId() + dept.getName() ) ); + } else { + deptMap.put( "checked", false ); + } + trees.add( deptMap ); + } + } + return trees; + } + + /** + * 查询课程分类人数 + * + * @param parentId 课程分类ID + * @return 结果 + */ + @Override + public int selectDeptCount(Long parentId) { + TrainCourseCategory dept = new TrainCourseCategory(); + dept.setParentId( parentId ); + return trainCourseCategoryMapper.selectDeptCount( dept ); + } + + /** + * 查询课程分类是否存在用户 + * + * @param deptId 课程分类ID + * @return 结果 true 存在 false 不存在 + */ + @Override + public boolean checkDeptExistUser(Long deptId) { + int result = trainCourseCategoryMapper.checkDeptExistUser( deptId ); + return result > 0 ? true : false; + } + + /** + * 删除课程分类管理信息 + * + * @param deptId 课程分类ID + * @return 结果 + */ + @Override + public int deleteDeptById(Long deptId) { + return trainCourseCategoryMapper.deleteDeptById( deptId ); + } + + /** + * 新增保存课程分类信息 + * + * @param dept 课程分类信息 + * @return 结果 + */ + @Override + public int insertDept(TrainCourseCategory dept) { + TrainCourseCategory info = trainCourseCategoryMapper.selectDeptById( dept.getParentId() ); + dept.setParentIds( info.getParentIds() + "," + dept.getParentId() ); + return trainCourseCategoryMapper.insertDept( dept ); + } + + /** + * 修改保存课程分类信息 + * + * @param dept 课程分类信息 + * @return 结果 + */ + @Override + public int updateDept(TrainCourseCategory dept) { + TrainCourseCategory info = trainCourseCategoryMapper.selectDeptById( dept.getParentId() ); + if (StringUtils.isNotNull( info )) { + String ancestors = info.getParentIds() + "," + dept.getParentId(); + dept.setParentIds( ancestors ); + updateDeptChildren( dept.getDeptId(), ancestors ); + } + return trainCourseCategoryMapper.updateDept( dept ); + } + + /** + * 修改子元素关系 + * + * @param deptId 课程分类ID + * @param ancestors 元素列表 + */ + public void updateDeptChildren(Long deptId, String ancestors) { + TrainCourseCategory dept = new TrainCourseCategory(); + dept.setParentId( deptId ); + List childrens = trainCourseCategoryMapper.selectDeptList( dept ); + for (TrainCourseCategory children : childrens) { + children.setParentIds( ancestors + "," + dept.getParentId() ); + } + if (childrens.size() > 0) { + trainCourseCategoryMapper.updateDeptChildren( childrens ); + } + } + + /** + * 根据课程分类ID查询信息 + * + * @param deptId 课程分类ID + * @return 课程分类信息 + */ + @Override + public TrainCourseCategory selectDeptById(Long deptId) { + return trainCourseCategoryMapper.selectDeptById( deptId ); + } + + /** + * 校验课程分类名称是否唯一 + * + * @param dept 课程分类信息 + * @return 结果 + */ + @Override + public String checkDeptNameUnique(TrainCourseCategory dept) { + Long deptId = StringUtils.isNull( dept.getDeptId() ) ? -1L : dept.getDeptId(); + TrainCourseCategory info = trainCourseCategoryMapper.checkDeptNameUnique( dept.getName(), dept.getParentId() ); + if (StringUtils.isNotNull( info ) && info.getDeptId().longValue() != deptId.longValue()) { + return UserConstants.DEPT_NAME_NOT_UNIQUE; + } + return UserConstants.DEPT_NAME_UNIQUE; + } +} diff --git a/ruoyi-train/src/main/java/com/ruoyi/courseware/controller/TrainCoursewareCategoryController.java b/ruoyi-train/src/main/java/com/ruoyi/courseware/controller/TrainCoursewareCategoryController.java new file mode 100644 index 000000000..8eeb59380 --- /dev/null +++ b/ruoyi-train/src/main/java/com/ruoyi/courseware/controller/TrainCoursewareCategoryController.java @@ -0,0 +1,152 @@ +package com.ruoyi.courseware.controller; + +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.base.AjaxResult; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.courseware.domain.TrainCoursewareCategory; +import com.ruoyi.courseware.service.ITrainCoursewareCategoryService; +import com.ruoyi.framework.web.base.BaseController; +import com.ruoyi.framework.web.util.ShiroUtils; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.ModelMap; +import org.springframework.web.bind.annotation.*; + +import java.util.List; +import java.util.Map; + +/** + * 课件分类信息 + * + * @author ruoyi + */ +@Controller +@RequestMapping("/train/courseware/category") +public class TrainCoursewareCategoryController extends BaseController +{ + private String prefix = "courseware/category"; + + @Autowired + private ITrainCoursewareCategoryService trainCoursewareCategoryService; + + @RequiresPermissions("train:courseware:category:view") + @GetMapping() + public String dept() + { + return prefix + "/dept"; + } + + @RequiresPermissions("train:courseware:category:list") + @GetMapping("/list") + @ResponseBody + public List list(TrainCoursewareCategory dept) + { + List deptList = trainCoursewareCategoryService.selectDeptList(dept); + return deptList; + } + + /** + * 新增课件分类 + */ + @GetMapping("/add/{parentId}") + public String add(@PathVariable("parentId") Long parentId, ModelMap mmap) + { + mmap.put("dept", trainCoursewareCategoryService.selectDeptById(parentId)); + return prefix + "/add"; + } + + /** + * 新增保存课件分类 + */ + @Log(title = "课件分类管理", businessType = BusinessType.INSERT) + @RequiresPermissions("train:courseware:category:add") + @PostMapping("/add") + @ResponseBody + public AjaxResult addSave(TrainCoursewareCategory dept) + { + dept.setCreateBy(ShiroUtils.getLoginName()); + return toAjax(trainCoursewareCategoryService.insertDept(dept)); + } + + /** + * 修改 + */ + @GetMapping("/edit/{deptId}") + public String edit(@PathVariable("deptId") Long deptId, ModelMap mmap) + { + TrainCoursewareCategory dept = trainCoursewareCategoryService.selectDeptById(deptId); + if (StringUtils.isNotNull(dept) && 100L == deptId) + { + dept.setParentName("无"); + } + mmap.put("dept", dept); + return prefix + "/edit"; + } + + /** + * 保存 + */ + @Log(title = "课件分类管理", businessType = BusinessType.UPDATE) + @RequiresPermissions("train:courseware:category:edit") + @PostMapping("/edit") + @ResponseBody + public AjaxResult editSave(TrainCoursewareCategory dept) + { + dept.setUpdateBy(ShiroUtils.getLoginName()); + return toAjax(trainCoursewareCategoryService.updateDept(dept)); + } + + /** + * 删除 + */ + @Log(title = "课件分类管理", businessType = BusinessType.DELETE) + @RequiresPermissions("train:courseware:category:remove") + @PostMapping("/remove/{deptId}") + @ResponseBody + public AjaxResult remove(@PathVariable("deptId") Long deptId) + { + if (trainCoursewareCategoryService.selectDeptCount(deptId) > 0) + { + return error(1, "存在下级课件分类,不允许删除"); + } + if (trainCoursewareCategoryService.checkDeptExistUser(deptId)) + { + return error(1, "课件分类存在用户,不允许删除"); + } + return toAjax(trainCoursewareCategoryService.deleteDeptById(deptId)); + } + + /** + * 校验课件分类名称 + */ + @PostMapping("/checkDeptNameUnique") + @ResponseBody + public String checkDeptNameUnique(TrainCoursewareCategory dept) + { + return trainCoursewareCategoryService.checkDeptNameUnique(dept); + } + + /** + * 选择课件分类树 + */ + @GetMapping("/selectDeptTree/{deptId}") + public String selectDeptTree(@PathVariable("deptId") Long deptId, ModelMap mmap) + { + mmap.put("dept", trainCoursewareCategoryService.selectDeptById(deptId)); + return prefix + "/tree"; + } + + /** + * 加载课件分类列表树 + */ + @GetMapping("/treeData") + @ResponseBody + public List> treeData() + { + List> tree = trainCoursewareCategoryService.selectDeptTree(); + return tree; + } + +} diff --git a/ruoyi-train/src/main/java/com/ruoyi/courseware/controller/VideoController.java b/ruoyi-train/src/main/java/com/ruoyi/courseware/controller/VideoController.java new file mode 100644 index 000000000..6ffd6dbce --- /dev/null +++ b/ruoyi-train/src/main/java/com/ruoyi/courseware/controller/VideoController.java @@ -0,0 +1,43 @@ +package com.ruoyi.courseware.controller; + +import com.aliyuncs.DefaultAcsClient; +import com.aliyuncs.exceptions.ClientException; +import com.aliyuncs.exceptions.ServerException; +import com.aliyuncs.profile.DefaultProfile; +import com.aliyuncs.vod.model.v20170321.GetVideoPlayAuthRequest; +import com.aliyuncs.vod.model.v20170321.GetVideoPlayAuthResponse; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; + +@Controller +@RequestMapping("/train/courseware/video") +public class VideoController { + + @GetMapping("") + public GetVideoPlayAuthResponse authority(){ + DefaultProfile profile = DefaultProfile.getProfile("cn-shanghai", "LTAIo1i5PQB4pFme", "NyiVe3pqbVOMnwMQxnOkV39KrTx2jR"); + DefaultAcsClient client = new DefaultAcsClient(profile); + GetVideoPlayAuthResponse response = getVideoPlayAuth(client); + System.out.println(response.getPlayAuth()); + System.out.println(response.getVideoMeta()); + return response; + } + + + private GetVideoPlayAuthResponse getVideoPlayAuth(DefaultAcsClient client) { + GetVideoPlayAuthRequest request = new GetVideoPlayAuthRequest(); + request.setVideoId("ID3dbb151b73c34b678efff61d3d50d999"); + GetVideoPlayAuthResponse response = null; + try { + response = client.getAcsResponse(request); + } catch (ServerException e) { + throw new RuntimeException("GetVideoPlayAuthRequest Server failed"); + } catch (ClientException e) { + throw new RuntimeException("GetVideoPlayAuthRequest Client failed"); + } + response.getPlayAuth(); // 播放凭证 + response.getVideoMeta(); // 视频Meta信息 + return response; + } +} diff --git a/ruoyi-train/src/main/java/com/ruoyi/courseware/domain/TrainCoursewareCategory.java b/ruoyi-train/src/main/java/com/ruoyi/courseware/domain/TrainCoursewareCategory.java new file mode 100644 index 000000000..538ef6029 --- /dev/null +++ b/ruoyi-train/src/main/java/com/ruoyi/courseware/domain/TrainCoursewareCategory.java @@ -0,0 +1,132 @@ +package com.ruoyi.courseware.domain; + +import com.ruoyi.common.base.BaseEntity; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +import javax.persistence.Id; + +/** + * 课件分类表 sys_dept + * + * @author ruoyi + */ +public class TrainCoursewareCategory extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 分类ID */ + @Id + private Long id; + /** + * 课件分类 + */ + private Long deptId; + /** 父课件分类ID */ + private Long parentId; + + /** 祖级列表 */ + private String parentIds; + + /** 课件分类名称 */ + private String name; + + /** 显示顺序 */ + private String orderNum; + + /** 删除标志(0代表存在 2代表删除) */ + private String delFlag; + + /** 父课件分类名称 */ + private String parentName; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Long getDeptId() { + return deptId; + } + + public void setDeptId(Long deptId) { + this.deptId = deptId; + } + + public Long getParentId() + { + return parentId; + } + + public void setParentId(Long parentId) + { + this.parentId = parentId; + } + + public String getParentIds() { + return parentIds; + } + + public void setParentIds(String parentIds) { + this.parentIds = parentIds; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getOrderNum() + { + return orderNum; + } + + public void setOrderNum(String orderNum) + { + this.orderNum = orderNum; + } + + + public String getDelFlag() + { + return delFlag; + } + + public void setDelFlag(String delFlag) + { + this.delFlag = delFlag; + } + + public String getParentName() + { + return parentName; + } + + public void setParentName(String parentName) + { + this.parentName = parentName; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("deptId", getDeptId()) + .append("parentId", getParentId()) + .append("ancestors", getParentIds()) + .append("deptName", getName()) + .append("orderNum", getOrderNum()) + .append("delFlag", getDelFlag()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .toString(); + } +} diff --git a/ruoyi-train/src/main/java/com/ruoyi/courseware/mapper/TrainCoursewareCategoryMapper.java b/ruoyi-train/src/main/java/com/ruoyi/courseware/mapper/TrainCoursewareCategoryMapper.java new file mode 100644 index 000000000..4e6da790b --- /dev/null +++ b/ruoyi-train/src/main/java/com/ruoyi/courseware/mapper/TrainCoursewareCategoryMapper.java @@ -0,0 +1,96 @@ +package com.ruoyi.courseware.mapper; + +import com.ruoyi.courseware.domain.TrainCoursewareCategory; +import com.ruoyi.framework.web.base.MyMapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 课件分类管理 数据层 + * + * @author ruoyi + */ +public interface TrainCoursewareCategoryMapper extends MyMapper +{ + /** + * 查询课件分类人数 + * + * @param dept 课件分类信息 + * @return 结果 + */ + public int selectDeptCount(TrainCoursewareCategory dept); + + /** + * 查询课件分类是否存在用户 + * + * @param deptId 课件分类ID + * @return 结果 + */ + public int checkDeptExistUser(Long deptId); + + /** + * 查询课件分类管理数据 + * + * @param dept 课件分类信息 + * @return 课件分类信息集合 + */ + public List selectDeptList(TrainCoursewareCategory dept); + + /** + * 删除课件分类管理信息 + * + * @param deptId 课件分类ID + * @return 结果 + */ + public int deleteDeptById(Long deptId); + + /** + * 新增课件分类信息 + * + * @param dept 课件分类信息 + * @return 结果 + */ + public int insertDept(TrainCoursewareCategory dept); + + /** + * 修改课件分类信息 + * + * @param dept 课件分类信息 + * @return 结果 + */ + public int updateDept(TrainCoursewareCategory dept); + + /** + * 修改子元素关系 + * + * @param depts 子元素 + * @return 结果 + */ + public int updateDeptChildren(@Param("depts") List depts); + + /** + * 根据课件分类ID查询信息 + * + * @param deptId 课件分类ID + * @return 课件分类信息 + */ + public TrainCoursewareCategory selectDeptById(Long deptId); + + /** + * 校验课件分类名称是否唯一 + * + * @param deptName 课件分类名称 + * @param parentId 父课件分类ID + * @return 结果 + */ + public TrainCoursewareCategory checkDeptNameUnique(@Param("deptName") String deptName, @Param("parentId") Long parentId); + + /** + * 根据角色ID查询课件分类 + * + * @param roleId 角色ID + * @return 课件分类列表 + */ + public List selectRoleDeptTree(Long roleId); +} diff --git a/ruoyi-train/src/main/java/com/ruoyi/courseware/service/ITrainCoursewareCategoryService.java b/ruoyi-train/src/main/java/com/ruoyi/courseware/service/ITrainCoursewareCategoryService.java new file mode 100644 index 000000000..e0aa88c68 --- /dev/null +++ b/ruoyi-train/src/main/java/com/ruoyi/courseware/service/ITrainCoursewareCategoryService.java @@ -0,0 +1,88 @@ +package com.ruoyi.courseware.service; + +import com.ruoyi.courseware.domain.TrainCoursewareCategory; +import com.ruoyi.framework.web.base.AbstractBaseService; + +import java.util.List; +import java.util.Map; + +/** + * 课件分类管理 服务层 + * + * @author ruoyi + */ +public interface ITrainCoursewareCategoryService extends AbstractBaseService +{ + /** + * 查询课件分类管理数据 + * + * @param dept 课件分类信息 + * @return 课件分类信息集合 + */ + public List selectDeptList(TrainCoursewareCategory dept); + + /** + * 查询课件分类管理树 + * + * @return 所有课件分类信息 + */ + public List> selectDeptTree(); + + + + /** + * 查询课件分类人数 + * + * @param parentId 父课件分类ID + * @return 结果 + */ + public int selectDeptCount(Long parentId); + + /** + * 查询课件分类是否存在用户 + * + * @param deptId 课件分类ID + * @return 结果 true 存在 false 不存在 + */ + public boolean checkDeptExistUser(Long deptId); + + /** + * 删除课件分类管理信息 + * + * @param deptId 课件分类ID + * @return 结果 + */ + public int deleteDeptById(Long deptId); + + /** + * 新增保存课件分类信息 + * + * @param dept 课件分类信息 + * @return 结果 + */ + public int insertDept(TrainCoursewareCategory dept); + + /** + * 修改保存课件分类信息 + * + * @param dept 课件分类信息 + * @return 结果 + */ + public int updateDept(TrainCoursewareCategory dept); + + /** + * 根据课件分类ID查询信息 + * + * @param deptId 课件分类ID + * @return 课件分类信息 + */ + public TrainCoursewareCategory selectDeptById(Long deptId); + + /** + * 校验课件分类名称是否唯一 + * + * @param dept 课件分类信息 + * @return 结果 + */ + public String checkDeptNameUnique(TrainCoursewareCategory dept); +} diff --git a/ruoyi-train/src/main/java/com/ruoyi/courseware/service/impl/TrainCoursewareCategoryServiceImpl.java b/ruoyi-train/src/main/java/com/ruoyi/courseware/service/impl/TrainCoursewareCategoryServiceImpl.java new file mode 100644 index 000000000..1f8652acc --- /dev/null +++ b/ruoyi-train/src/main/java/com/ruoyi/courseware/service/impl/TrainCoursewareCategoryServiceImpl.java @@ -0,0 +1,191 @@ +package com.ruoyi.courseware.service.impl; + +import com.ruoyi.common.annotation.DataScope; +import com.ruoyi.common.constant.UserConstants; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.courseware.domain.TrainCoursewareCategory; +import com.ruoyi.courseware.mapper.TrainCoursewareCategoryMapper; +import com.ruoyi.courseware.service.ITrainCoursewareCategoryService; +import com.ruoyi.framework.web.base.AbstractBaseServiceImpl; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 课件分类管理 服务实现 + * + * @author ruoyi + */ +@Service +public class TrainCoursewareCategoryServiceImpl extends AbstractBaseServiceImpl implements ITrainCoursewareCategoryService { + @Autowired + private TrainCoursewareCategoryMapper trainCoursewareCategoryMapper; + /** + * 查询课件分类管理数据 + * + * @return 课件分类信息集合 + */ + @Override + @DataScope(tableAlias = "d") + public List selectDeptList(TrainCoursewareCategory dept) { + return trainCoursewareCategoryMapper.selectDeptList( dept ); + } + + /** + * 查询课件分类管理树 + * + * @return 所有课件分类信息 + */ + @Override + public List> selectDeptTree() { + List> trees = new ArrayList>(); + List deptList = selectDeptList( new TrainCoursewareCategory() ); + trees = getTrees( deptList, false, null ); + return trees; + } + + + /** + * 对象转课件分类树 + * + * @param deptList 课件分类列表 + * @param isCheck 是否需要选中 + * @param roleDeptList 角色已存在菜单列表 + * @return + */ + public List> getTrees(List deptList, boolean isCheck, List roleDeptList) { + + List> trees = new ArrayList>(); + for (TrainCoursewareCategory dept : deptList) { + if (UserConstants.DEPT_NORMAL.equals( dept.getDelFlag() )) { + Map deptMap = new HashMap(); + deptMap.put( "id", dept.getId() ); + deptMap.put( "pId", dept.getParentId() ); + deptMap.put( "name", dept.getName() ); + deptMap.put( "title", dept.getName() ); + if (isCheck) { + deptMap.put( "checked", roleDeptList.contains( dept.getDeptId() + dept.getName() ) ); + } else { + deptMap.put( "checked", false ); + } + trees.add( deptMap ); + } + } + return trees; + } + + /** + * 查询课件分类人数 + * + * @param parentId 课件分类ID + * @return 结果 + */ + @Override + public int selectDeptCount(Long parentId) { + TrainCoursewareCategory dept = new TrainCoursewareCategory(); + dept.setParentId( parentId ); + return trainCoursewareCategoryMapper.selectDeptCount( dept ); + } + + /** + * 查询课件分类是否存在用户 + * + * @param deptId 课件分类ID + * @return 结果 true 存在 false 不存在 + */ + @Override + public boolean checkDeptExistUser(Long deptId) { + int result = trainCoursewareCategoryMapper.checkDeptExistUser( deptId ); + return result > 0 ? true : false; + } + + /** + * 删除课件分类管理信息 + * + * @param deptId 课件分类ID + * @return 结果 + */ + @Override + public int deleteDeptById(Long deptId) { + return trainCoursewareCategoryMapper.deleteDeptById( deptId ); + } + + /** + * 新增保存课件分类信息 + * + * @param dept 课件分类信息 + * @return 结果 + */ + @Override + public int insertDept(TrainCoursewareCategory dept) { + TrainCoursewareCategory info = trainCoursewareCategoryMapper.selectDeptById( dept.getParentId() ); + dept.setParentIds( info.getParentIds() + "," + dept.getParentId() ); + return trainCoursewareCategoryMapper.insertDept( dept ); + } + + /** + * 修改保存课件分类信息 + * + * @param dept 课件分类信息 + * @return 结果 + */ + @Override + public int updateDept(TrainCoursewareCategory dept) { + TrainCoursewareCategory info = trainCoursewareCategoryMapper.selectDeptById( dept.getParentId() ); + if (StringUtils.isNotNull( info )) { + String ancestors = info.getParentIds() + "," + dept.getParentId(); + dept.setParentIds( ancestors ); + updateDeptChildren( dept.getDeptId(), ancestors ); + } + return trainCoursewareCategoryMapper.updateDept( dept ); + } + + /** + * 修改子元素关系 + * + * @param deptId 课件分类ID + * @param ancestors 元素列表 + */ + public void updateDeptChildren(Long deptId, String ancestors) { + TrainCoursewareCategory dept = new TrainCoursewareCategory(); + dept.setParentId( deptId ); + List childrens = trainCoursewareCategoryMapper.selectDeptList( dept ); + for (TrainCoursewareCategory children : childrens) { + children.setParentIds( ancestors + "," + dept.getParentId() ); + } + if (childrens.size() > 0) { + trainCoursewareCategoryMapper.updateDeptChildren( childrens ); + } + } + + /** + * 根据课件分类ID查询信息 + * + * @param deptId 课件分类ID + * @return 课件分类信息 + */ + @Override + public TrainCoursewareCategory selectDeptById(Long deptId) { + return trainCoursewareCategoryMapper.selectDeptById( deptId ); + } + + /** + * 校验课件分类名称是否唯一 + * + * @param dept 课件分类信息 + * @return 结果 + */ + @Override + public String checkDeptNameUnique(TrainCoursewareCategory dept) { + Long deptId = StringUtils.isNull( dept.getDeptId() ) ? -1L : dept.getDeptId(); + TrainCoursewareCategory info = trainCoursewareCategoryMapper.checkDeptNameUnique( dept.getName(), dept.getParentId() ); + if (StringUtils.isNotNull( info ) && info.getDeptId().longValue() != deptId.longValue()) { + return UserConstants.DEPT_NAME_NOT_UNIQUE; + } + return UserConstants.DEPT_NAME_UNIQUE; + } +} diff --git a/ruoyi-train/src/main/java/com/ruoyi/courseware/utils/VideoUtils.java b/ruoyi-train/src/main/java/com/ruoyi/courseware/utils/VideoUtils.java new file mode 100644 index 000000000..f14b7fff6 --- /dev/null +++ b/ruoyi-train/src/main/java/com/ruoyi/courseware/utils/VideoUtils.java @@ -0,0 +1,39 @@ +package com.ruoyi.courseware.utils; + +import com.aliyuncs.DefaultAcsClient; +import com.aliyuncs.exceptions.ClientException; +import com.aliyuncs.exceptions.ServerException; +import com.aliyuncs.profile.DefaultProfile; +import com.aliyuncs.vod.model.v20170321.GetVideoPlayAuthRequest; +import com.aliyuncs.vod.model.v20170321.GetVideoPlayAuthResponse; + +public class VideoUtils { + + // 设置AccessKey ID和AccessKey secret + private static String access_key_id = "LTAILL4H4JcoUJdf"; + private static String access_key_secret = "6TtJ1MD7ueolOXWjx0VhaseX6nkPVe "; + + public static void main(String[] args) { + // 点播服务所在的地域,中国大陆地域请填cn-shanghai + DefaultProfile profile = DefaultProfile.getProfile("cn-shanghai", access_key_id, access_key_secret); + DefaultAcsClient client = new DefaultAcsClient(profile); + // 传入视频ID + GetVideoPlayAuthResponse response = getVideoPlayAuth(client, "3dbb151b73c34b678efff61d3d50d999"); + System.out.println(response.getPlayAuth()); + } + + private static GetVideoPlayAuthResponse getVideoPlayAuth(DefaultAcsClient client, String videoId) { + GetVideoPlayAuthRequest request = new GetVideoPlayAuthRequest(); + request.setVideoId(videoId); + GetVideoPlayAuthResponse response = null; + try { + response = client.getAcsResponse(request); + } catch (ServerException e) { + throw new RuntimeException("GetVideoPlayAuthRequest Server failed"); + } catch (ClientException e) { + throw new RuntimeException("GetVideoPlayAuthRequest Client failed"); + } + return response; + } + +} diff --git a/ruoyi-train/src/main/resources/mapper/course/TrainCourseCategoryMapper.xml b/ruoyi-train/src/main/resources/mapper/course/TrainCourseCategoryMapper.xml new file mode 100644 index 000000000..f016c9f4c --- /dev/null +++ b/ruoyi-train/src/main/resources/mapper/course/TrainCourseCategoryMapper.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + select d.id,d.dept_id, d.parent_id, d.parent_ids, d.name, d.order_num, d.del_flag, d.create_by, d.create_time + from train_courseware_category d + + + + + + + + + + + + + + + insert into train_courseware_category( + id, + parent_id, + name, + parent_ids, + order_num, + + create_by, + create_time + )values( + #{id}, + #{parentId}, + #{name}, + #{parentIds}, + #{orderNum}, + + #{createBy}, + sysdate() + ) + + + + update train_courseware_category + + parent_id = #{parentId}, + name = #{name}, + parent_ids = #{parentIds}, + order_num = #{orderNum}, + + update_by = #{updateBy}, + update_time = sysdate() + + where id = #{id} + + + + update train_courseware_category set parent_ids = + + when #{item.id} then #{item.parent_ids} + + where id in + + #{item.id} + + + + + update train_courseware_category set del_flag = '2' where id = #{id} + + + \ No newline at end of file diff --git a/ruoyi-train/src/main/resources/mapper/courseware/TrainCoursewareCategoryMapper.xml b/ruoyi-train/src/main/resources/mapper/courseware/TrainCoursewareCategoryMapper.xml new file mode 100644 index 000000000..3a2d39f6f --- /dev/null +++ b/ruoyi-train/src/main/resources/mapper/courseware/TrainCoursewareCategoryMapper.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + select d.id,d.dept_id, d.parent_id, d.parent_ids, d.name, d.order_num, d.del_flag, d.create_by, d.create_time + from train_courseware_category d + + + + + + + + + + + + + + + insert into train_courseware_category( + id, + parent_id, + name, + parent_ids, + order_num, + + create_by, + create_time + )values( + #{id}, + #{parentId}, + #{name}, + #{parentIds}, + #{orderNum}, + + #{createBy}, + sysdate() + ) + + + + update train_courseware_category + + parent_id = #{parentId}, + name = #{name}, + parent_ids = #{parentIds}, + order_num = #{orderNum}, + + update_by = #{updateBy}, + update_time = sysdate() + + where id = #{id} + + + + update train_courseware_category set parent_ids = + + when #{item.id} then #{item.parent_ids} + + where id in + + #{item.id} + + + + + update train_courseware_category set del_flag = '2' where id = #{id} + + + \ No newline at end of file diff --git a/ruoyi-train/src/main/resources/templates/course/category/add.html b/ruoyi-train/src/main/resources/templates/course/category/add.html new file mode 100644 index 000000000..eed964d11 --- /dev/null +++ b/ruoyi-train/src/main/resources/templates/course/category/add.html @@ -0,0 +1,124 @@ + + + + + +
+
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
+ + +
+
+
+
+
+
+ + + diff --git a/ruoyi-train/src/main/resources/templates/course/category/dept.html b/ruoyi-train/src/main/resources/templates/course/category/dept.html new file mode 100644 index 000000000..0ed1808c5 --- /dev/null +++ b/ruoyi-train/src/main/resources/templates/course/category/dept.html @@ -0,0 +1,115 @@ + + + + + +
+
+
+
+
+ +
+
+
+ + +
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/ruoyi-train/src/main/resources/templates/course/category/edit.html b/ruoyi-train/src/main/resources/templates/course/category/edit.html new file mode 100644 index 000000000..4277c47bd --- /dev/null +++ b/ruoyi-train/src/main/resources/templates/course/category/edit.html @@ -0,0 +1,133 @@ + + + + + +
+
+ + +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
+ + +
+
+
+
+
+
+ + + diff --git a/ruoyi-train/src/main/resources/templates/course/category/tree.html b/ruoyi-train/src/main/resources/templates/course/category/tree.html new file mode 100644 index 000000000..4b91ac8a7 --- /dev/null +++ b/ruoyi-train/src/main/resources/templates/course/category/tree.html @@ -0,0 +1,48 @@ + + + + + + + + + +
+ + +
+ +
+ 展开 / + 折叠 +
+
+
+
+ + + + diff --git a/ruoyi-train/src/main/resources/templates/courseware/category/add.html b/ruoyi-train/src/main/resources/templates/courseware/category/add.html new file mode 100644 index 000000000..c058bd234 --- /dev/null +++ b/ruoyi-train/src/main/resources/templates/courseware/category/add.html @@ -0,0 +1,124 @@ + + + + + +
+
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
+ + +
+
+
+
+
+
+ + + diff --git a/ruoyi-train/src/main/resources/templates/courseware/category/dept.html b/ruoyi-train/src/main/resources/templates/courseware/category/dept.html new file mode 100644 index 000000000..80b86ce00 --- /dev/null +++ b/ruoyi-train/src/main/resources/templates/courseware/category/dept.html @@ -0,0 +1,115 @@ + + + + + +
+
+
+
+
+ +
+
+
+ + +
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/ruoyi-train/src/main/resources/templates/courseware/category/edit.html b/ruoyi-train/src/main/resources/templates/courseware/category/edit.html new file mode 100644 index 000000000..c0e03def1 --- /dev/null +++ b/ruoyi-train/src/main/resources/templates/courseware/category/edit.html @@ -0,0 +1,133 @@ + + + + + +
+
+ + +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
+ + +
+
+
+
+
+
+ + + diff --git a/ruoyi-train/src/main/resources/templates/courseware/category/tree.html b/ruoyi-train/src/main/resources/templates/courseware/category/tree.html new file mode 100644 index 000000000..a396e18ab --- /dev/null +++ b/ruoyi-train/src/main/resources/templates/courseware/category/tree.html @@ -0,0 +1,48 @@ + + + + + + + + + +
+ + +
+ +
+ 展开 / + 折叠 +
+
+
+
+ + + +