|
|
@ -1,12 +1,24 @@ |
|
|
package com.zdxt.auth.project.system.notice.service; |
|
|
package com.zdxt.auth.project.system.notice.service; |
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
|
|
import cn.hutool.core.util.IdUtil; |
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
|
|
import com.zdxt.auth.dto.ZdxtFileBean; |
|
|
|
|
|
import com.zdxt.auth.feign.FileUploadApi; |
|
|
|
|
|
import com.zdxt.auth.feign.ZdxtFileCommonApi; |
|
|
|
|
|
import com.zdxt.common.zdxtFile.AttFileRespDTO; |
|
|
|
|
|
import com.zdxt.common.zdxtFile.FilePreviewUtilBean; |
|
|
|
|
|
import com.zdxt.common.zdxtFile.ZdxtFileCommon; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
import com.zdxt.auth.common.utils.security.ShiroUtils; |
|
|
import com.zdxt.auth.common.utils.security.ShiroUtils; |
|
|
import com.zdxt.auth.common.utils.text.Convert; |
|
|
import com.zdxt.auth.common.utils.text.Convert; |
|
|
import com.zdxt.auth.project.system.notice.mapper.NoticeMapper; |
|
|
import com.zdxt.auth.project.system.notice.mapper.NoticeMapper; |
|
|
import com.zdxt.auth.project.system.notice.domain.Notice; |
|
|
import com.zdxt.auth.project.system.notice.domain.Notice; |
|
|
|
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 公告 服务层实现 |
|
|
* 公告 服务层实现 |
|
|
@ -20,6 +32,12 @@ public class NoticeServiceImpl implements INoticeService |
|
|
@Autowired |
|
|
@Autowired |
|
|
private NoticeMapper noticeMapper; |
|
|
private NoticeMapper noticeMapper; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
private ZdxtFileCommonApi zdxtFileCommonApi; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
private FileUploadApi fileUploadApi; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 查询公告信息 |
|
|
* 查询公告信息 |
|
|
* |
|
|
* |
|
|
@ -27,7 +45,7 @@ public class NoticeServiceImpl implements INoticeService |
|
|
* @return 公告信息 |
|
|
* @return 公告信息 |
|
|
*/ |
|
|
*/ |
|
|
@Override |
|
|
@Override |
|
|
public Notice selectNoticeById(Long noticeId) |
|
|
public Notice selectNoticeById(String noticeId) |
|
|
{ |
|
|
{ |
|
|
return noticeMapper.selectNoticeById(noticeId); |
|
|
return noticeMapper.selectNoticeById(noticeId); |
|
|
} |
|
|
} |
|
|
@ -53,10 +71,27 @@ public class NoticeServiceImpl implements INoticeService |
|
|
@Override |
|
|
@Override |
|
|
public int insertNotice(Notice notice) |
|
|
public int insertNotice(Notice notice) |
|
|
{ |
|
|
{ |
|
|
|
|
|
notice.setNoticeId(IdUtil.fastSimpleUUID()); |
|
|
notice.setCreateBy(ShiroUtils.getLoginName()); |
|
|
notice.setCreateBy(ShiroUtils.getLoginName()); |
|
|
return noticeMapper.insertNotice(notice); |
|
|
return noticeMapper.insertNotice(notice); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public int addNotice(MultipartFile[] files, Notice notice) { |
|
|
|
|
|
String busId = IdUtil.fastSimpleUUID(); |
|
|
|
|
|
notice.setNoticeId(busId); |
|
|
|
|
|
notice.setCreateBy(ShiroUtils.getLoginName()); |
|
|
|
|
|
// 上传文件,并在附件表中添加记录
|
|
|
|
|
|
if (ObjectUtil.isNotEmpty(files)) { |
|
|
|
|
|
for (MultipartFile file : files) { |
|
|
|
|
|
if(file.getOriginalFilename() != null && !"".equals(file.getOriginalFilename())){ |
|
|
|
|
|
zdxtFileCommonApi.insertZdxtFile(file, busId, fileUploadApi.upload(file)); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return noticeMapper.insertNotice(notice); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 修改公告 |
|
|
* 修改公告 |
|
|
* |
|
|
* |
|
|
@ -70,6 +105,20 @@ public class NoticeServiceImpl implements INoticeService |
|
|
return noticeMapper.updateNotice(notice); |
|
|
return noticeMapper.updateNotice(notice); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public int editNoticeFile(MultipartFile[] files, Notice notice) { |
|
|
|
|
|
// 上传文件,并在附件表中添加记录
|
|
|
|
|
|
if (ObjectUtil.isNotEmpty(files)) { |
|
|
|
|
|
for (MultipartFile file : files) { |
|
|
|
|
|
if(file.getOriginalFilename() != null && !"".equals(file.getOriginalFilename())){ |
|
|
|
|
|
zdxtFileCommonApi.insertZdxtFile(file, notice.getNoticeId(), fileUploadApi.upload(file)); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
notice.setUpdateBy(ShiroUtils.getLoginName()); |
|
|
|
|
|
return noticeMapper.updateNotice(notice); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 删除公告对象 |
|
|
* 删除公告对象 |
|
|
* |
|
|
* |
|
|
@ -81,4 +130,28 @@ public class NoticeServiceImpl implements INoticeService |
|
|
{ |
|
|
{ |
|
|
return noticeMapper.deleteNoticeByIds(Convert.toStrArray(ids)); |
|
|
return noticeMapper.deleteNoticeByIds(Convert.toStrArray(ids)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public AttFileRespDTO queryFiles(String noticeId) { |
|
|
|
|
|
ArrayList<ZdxtFileCommon> fileList = new ArrayList<>(); |
|
|
|
|
|
FilePreviewUtilBean filePreviewUtilBean = new FilePreviewUtilBean(); |
|
|
|
|
|
if(noticeId ==null || "".equals(noticeId)){ |
|
|
|
|
|
return filePreviewUtilBean.attachementToAttFileRespDTO(fileList); |
|
|
|
|
|
} |
|
|
|
|
|
ZdxtFileBean zdxtFileBeanCondition = new ZdxtFileBean(); |
|
|
|
|
|
zdxtFileBeanCondition.setBusinessId(noticeId); |
|
|
|
|
|
List<ZdxtFileBean> fileBeanList = zdxtFileCommonApi.selectZdxtFileList(zdxtFileBeanCondition); |
|
|
|
|
|
|
|
|
|
|
|
for (ZdxtFileBean fileBean : fileBeanList) { |
|
|
|
|
|
ZdxtFileCommon zdxtFileCommon = new ZdxtFileCommon(); |
|
|
|
|
|
BeanUtil.copyProperties(fileBean, zdxtFileCommon); |
|
|
|
|
|
fileList.add(zdxtFileCommon); |
|
|
|
|
|
} |
|
|
|
|
|
return filePreviewUtilBean.attachementToAttFileRespDTO(fileList); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public int removeFile(String key) { |
|
|
|
|
|
return zdxtFileCommonApi.deleteZdxtFileById(key); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|