添加目录的完成

main
whb 2 years ago
parent c93d3be8e5
commit b18a4e458f

Binary file not shown.

Before

Width:  |  Height:  |  Size: 191 KiB

@ -40,14 +40,6 @@ public class Directory {
private String dirImg;
/**
*
*/
@TableField(value = "dir_iden")
private String dirIden;
/**
*
*/

@ -7,7 +7,9 @@ import com.zhiyun.zhiyun03.course.vo.PageVO;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
*
*/
@Mapper
public interface CourseMapper extends BaseMapper<Course> {

@ -1,7 +1,9 @@
package com.zhiyun.zhiyun03.course.param;
import lombok.Data;
/**
*
*/
@Data
public class PageParam {
/**

@ -10,7 +10,9 @@ import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
/**
*
*/
public interface CourseService extends IService<Course> {
/**
@ -37,8 +39,13 @@ public interface CourseService extends IService<Course> {
* ID
*/
CourseVo queryCourseById(Integer id);
/**
*
*/
void addCourseDirectory(Directory directory);
/**
*
*/
List<DirectoryVo> queryCourseDirectory();
}

@ -83,7 +83,7 @@ public class CourseServiceImpl extends ServiceImpl<CourseMapper,Course> implemen
throw new ServiceException("403","该课程已经存在");
}
Course course = new Course();
/*将vo参数赋值给course*/
BeanUtils.copyProperties(courseVo,course);
//获取目录名称
@ -179,13 +179,17 @@ public class CourseServiceImpl extends ServiceImpl<CourseMapper,Course> implemen
}
return courseVo;
}
/**
*
*/
@Override
public void addCourseDirectory(Directory directory) {
/*判断目录名是否为空*/
if (directory.getDirName().isEmpty())
{
throw new ServiceException("400","目录名称不能为空");
}
/*判断目录图标是否为空*/
if (directory.getDirImg().isEmpty())
{
throw new ServiceException("400","请选择一个icon");
@ -196,7 +200,7 @@ public class CourseServiceImpl extends ServiceImpl<CourseMapper,Course> implemen
{
throw new ServiceException("400","目录已存在");
}
/*目录生成随机id*/
int uuid= UUID.randomUUID().hashCode();
if(uuid<0){
uuid=-uuid;
@ -205,7 +209,9 @@ public class CourseServiceImpl extends ServiceImpl<CourseMapper,Course> implemen
directory.setId(uuid);
directoryMapper.addCourseDirectory(directory);
}
/**
*
*/
@Override
public List<DirectoryVo> queryCourseDirectory() {

@ -30,13 +30,13 @@ public class DownloadServiceImpl extends ServiceImpl<DownloadMapper, Download> i
private DirectoryMapper directoryMapper;
/*
*
*
* */
@Override
public PageVO<DownloadVo> queryDownload(Integer page, Integer limit) {
//开启分页
PageHelper.startPage(page,limit);
PageHelper.startPage(page, limit);
//查询所有下载数据
List<DownloadVo> downloadVoList = downloadMapper.queryDownload();
@ -52,6 +52,7 @@ public class DownloadServiceImpl extends ServiceImpl<DownloadMapper, Download> i
return downloadVoPageVO;
}
/*
*
* */
@ -59,28 +60,28 @@ public class DownloadServiceImpl extends ServiceImpl<DownloadMapper, Download> i
public int addDownload(DownloadVo vo) {
//查询下载名称是否已经存在
int count = downloadMapper.selectByName(vo.getDownloadName());
if (count>0)
{
throw new ServiceException("403","下载已存在");
if (count > 0) {
throw new ServiceException("403", "下载已存在");
}
//将vo值传给download
Download download = new Download();
BeanUtils.copyProperties(vo,download);
BeanUtils.copyProperties(vo, download);
//查询归属目录id
Integer dirId = directoryMapper.selectByName(vo.getDirName(),"5");
if (dirId==null){
throw new ServiceException("400","目录不存在");
Integer dirId = directoryMapper.selectByName(vo.getDirName(), "5");
if (dirId == null) {
throw new ServiceException("400", "目录不存在");
}
/*设置目录id*/
download.setDirId(dirId);
/*设置更新时间*/
download.setDownloadUpdatetime(new Date());
//添加download
int insert = downloadMapper.insert(download);
if (insert>0)
{
if (insert > 0) {
return insert;
}else
{
throw new ServiceException("400","添加下载失败");
} else {
throw new ServiceException("400", "添加下载失败");
}
}
@ -89,21 +90,19 @@ public class DownloadServiceImpl extends ServiceImpl<DownloadMapper, Download> i
* */
@Override
public int delDownload(Integer id) {
if (id == null)
{
throw new ServiceException("400","查询id值为空");
if (id == null) {
throw new ServiceException("400", "查询id值为空");
}
//根据id删除
int count = downloadMapper.deleteById(id);
if (count>0)
{
if (count > 0) {
return count;
}else
{
throw new ServiceException("400","删除失败");
} else {
throw new ServiceException("400", "删除失败");
}
}
/*
* id
* */
@ -115,65 +114,64 @@ public class DownloadServiceImpl extends ServiceImpl<DownloadMapper, Download> i
Directory directory = directoryMapper.selectById(download.getDirId());
DownloadVo downloadAddVo = new DownloadVo();
//复制给vo
BeanUtils.copyProperties(download,downloadAddVo);
BeanUtils.copyProperties(download, downloadAddVo);
/*设置目录名*/
downloadAddVo.setDirName(directory.getDirName());
return downloadAddVo;
}
/*
*
* */
@Override
public int updateDownload(DownloadVo vo) {
/*条件判断*/
if (vo.getDownloadName().isEmpty())
{
throw new ServiceException("400","下载名不能为空失败");
if (vo.getDownloadName().isEmpty()) {
throw new ServiceException("400", "下载名不能为空失败");
}
//将vo值传给download
Download download = new Download();
BeanUtils.copyProperties(vo,download);
BeanUtils.copyProperties(vo, download);
//查询归属目录id
Integer dirId = directoryMapper.selectByName(vo.getDirName(),"5");
Integer dirId = directoryMapper.selectByName(vo.getDirName(), "5");
download.setDirId(dirId);
download.setDownloadUpdatetime(new Date());
//添加download
int insert = downloadMapper.updateDownloadById(download);
if (insert>0)
{
if (insert > 0) {
return insert;
}else
{
throw new ServiceException("400","更新失败");
} else {
throw new ServiceException("400", "更新失败");
}
}
/*添加下载目录*/
@Override
public void addDownloadDirectory(Directory directory) {
if (directory.getDirName().isEmpty())
{
throw new ServiceException("400","目录名称不能为空");
if (directory.getDirName().isEmpty()) {
throw new ServiceException("400", "目录名称不能为空");
}
if (directory.getDirImg().isEmpty())
{
throw new ServiceException("400","请选择一个icon");
if (directory.getDirImg().isEmpty()) {
throw new ServiceException("400", "请选择一个icon");
}
Integer count = directoryMapper.selectByName(directory.getDirName(),"5");
if (count!=null)
{
throw new ServiceException("400","目录已存在");
/*查询目录名是否存在*/
Integer count = directoryMapper.selectByName(directory.getDirName(), "5");
if (count != null) {
throw new ServiceException("400", "目录已存在");
}
int uuid= UUID.randomUUID().hashCode();
if(uuid<0){
uuid=-uuid;
/*目录生成随机id*/
int uuid = UUID.randomUUID().hashCode();
if (uuid < 0) {
uuid = -uuid;
}
directory.setDirAddtime(new Date());
directory.setId(uuid);
/*添加下载*/
directoryMapper.addDownloadDirectory(directory);
}
/*查询下载目录*/
@Override
public List<DirectoryVo> queryDownloadDirectory() {
List<DirectoryVo> directoryList = directoryMapper.queryDownloadDirectory();

@ -69,7 +69,6 @@ public class AliyunOssUtil {
client.shutdown();
}
}
return null;
}

@ -20,7 +20,10 @@ spring:
url: jdbc:mysql://localhost:3306/zhiyun?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai
username: root
password: root
servlet:
multipart:
max-file-size: 50MB
max-request-size: 50MB
# mybatis plus的配置和mybatis类似之前在mybatis的配置使用mybtis-plus替换
@ -39,4 +42,4 @@ pagehelper:
swagger:
enabled: true
enabled: false

@ -10,25 +10,6 @@
<div class="layui-layout layui-layout-admin">
<div class="layui-header">
<div class="layui-logo layui-hide-xs layui-bg-black">天择后台管业系统</div>
<!-- 头部区域可配合layui 已有的水平导航) -->
<!-- <ul class="layui-nav layui-layout-left">-->
<!-- &lt;!&ndash; 移动端显示 &ndash;&gt;-->
<!-- <li class="layui-nav-item layui-show-xs-inline-block layui-hide-sm" lay-header-event="menuLeft">-->
<!-- <i class="layui-icon layui-icon-spread-left"></i>-->
<!-- </li>-->
<!--&lt;!&ndash; <li class="layui-nav-item layui-hide-xs"><a href="">nav 1</a></li>&ndash;&gt;-->
<!--&lt;!&ndash; <li class="layui-nav-item layui-hide-xs"><a href="">nav 2</a></li>&ndash;&gt;-->
<!--&lt;!&ndash; <li class="layui-nav-item layui-hide-xs"><a href="">nav 3</a></li>&ndash;&gt;-->
<!--&lt;!&ndash; <li class="layui-nav-item">&ndash;&gt;-->
<!--&lt;!&ndash; <a href="javascript:;">nav groups</a>&ndash;&gt;-->
<!--&lt;!&ndash; <dl class="layui-nav-child">&ndash;&gt;-->
<!--&lt;!&ndash; <dd><a href="">menu 11</a></dd>&ndash;&gt;-->
<!--&lt;!&ndash; <dd><a href="">menu 22</a></dd>&ndash;&gt;-->
<!--&lt;!&ndash; <dd><a href="">menu 33</a></dd>&ndash;&gt;-->
<!--&lt;!&ndash; </dl>&ndash;&gt;-->
<!--&lt;!&ndash; </li>&ndash;&gt;-->
<!-- </ul>-->
<ul class="layui-nav layui-layout-right">
<li class="layui-nav-item layui-hide layui-show-md-inline-block">
<a href="javascript:;">

Loading…
Cancel
Save