|
|
|
@ -29,14 +29,14 @@ public class DownloadServiceImpl extends ServiceImpl<DownloadMapper, Download> i
|
|
|
|
|
@Resource
|
|
|
|
|
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,35 +52,36 @@ public class DownloadServiceImpl extends ServiceImpl<DownloadMapper, Download> i
|
|
|
|
|
|
|
|
|
|
return downloadVoPageVO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* 添加下载
|
|
|
|
|
* */
|
|
|
|
|
@Override
|
|
|
|
|
public int addDownload(DownloadVo vo) {
|
|
|
|
|
//查询下载名称是否已经存在
|
|
|
|
|
int count = downloadMapper.selectByName(vo.getDownloadName());
|
|
|
|
|
if (count>0)
|
|
|
|
|
{
|
|
|
|
|
throw new ServiceException("403","下载已存在");
|
|
|
|
|
}
|
|
|
|
|
int count = downloadMapper.selectByName(vo.getDownloadName());
|
|
|
|
|
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();
|
|
|
|
|