|
|
|
@ -2,16 +2,22 @@ package com.zdxt.auth.project.system.notice.service; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Objects; |
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
import cn.hutool.core.util.IdUtil; |
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
import com.zdxt.auth.common.utils.StringUtils; |
|
|
|
import com.zdxt.auth.dto.ZdxtFileBean; |
|
|
|
import com.zdxt.auth.feign.FileUploadApi; |
|
|
|
import com.zdxt.auth.feign.ZdxtFileCommonApi; |
|
|
|
import com.zdxt.auth.project.system.dept.mapper.DeptMapper; |
|
|
|
import com.zdxt.auth.project.system.dept.service.IDeptService; |
|
|
|
import com.zdxt.common.annotation.DataScope; |
|
|
|
import com.zdxt.common.zdxtFile.AttFileRespDTO; |
|
|
|
import com.zdxt.common.zdxtFile.FilePreviewUtilBean; |
|
|
|
import com.zdxt.common.zdxtFile.ZdxtFileCommon; |
|
|
|
import com.zdxt.domain.auth.Dept; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import com.zdxt.auth.common.utils.security.ShiroUtils; |
|
|
|
@ -22,7 +28,7 @@ import org.springframework.web.multipart.MultipartFile; |
|
|
|
|
|
|
|
/** |
|
|
|
* 公告 服务层实现 |
|
|
|
* |
|
|
|
* |
|
|
|
* @author ruoyi |
|
|
|
* @date 2018-06-25 |
|
|
|
*/ |
|
|
|
@ -32,6 +38,9 @@ public class NoticeServiceImpl implements INoticeService |
|
|
|
@Autowired |
|
|
|
private NoticeMapper noticeMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private DeptMapper deptMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private ZdxtFileCommonApi zdxtFileCommonApi; |
|
|
|
|
|
|
|
@ -40,7 +49,7 @@ public class NoticeServiceImpl implements INoticeService |
|
|
|
|
|
|
|
/** |
|
|
|
* 查询公告信息 |
|
|
|
* |
|
|
|
* |
|
|
|
* @param noticeId 公告ID |
|
|
|
* @return 公告信息 |
|
|
|
*/ |
|
|
|
@ -64,7 +73,7 @@ public class NoticeServiceImpl implements INoticeService |
|
|
|
|
|
|
|
/** |
|
|
|
* 查询公告列表 |
|
|
|
* |
|
|
|
* |
|
|
|
* @param notice 公告信息 |
|
|
|
* @return 公告集合 |
|
|
|
*/ |
|
|
|
@ -75,6 +84,7 @@ public class NoticeServiceImpl implements INoticeService |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@DataScope |
|
|
|
public List<Notice> selectNoticeListNoPermission(Notice notice) { |
|
|
|
List<Notice> list = |
|
|
|
noticeMapper.selectNoticeList(notice); |
|
|
|
@ -92,7 +102,7 @@ public class NoticeServiceImpl implements INoticeService |
|
|
|
|
|
|
|
/** |
|
|
|
* 新增公告 |
|
|
|
* |
|
|
|
* |
|
|
|
* @param notice 公告信息 |
|
|
|
* @return 结果 |
|
|
|
*/ |
|
|
|
@ -101,6 +111,23 @@ public class NoticeServiceImpl implements INoticeService |
|
|
|
{ |
|
|
|
notice.setNoticeId(IdUtil.fastSimpleUUID()); |
|
|
|
notice.setCreateBy(ShiroUtils.getLoginName()); |
|
|
|
//通过部门id获取部门名称
|
|
|
|
if (StringUtils.isNotEmpty(notice.getBureauDeptIds())) { |
|
|
|
StringBuilder deptNames = null; |
|
|
|
String[] strings = Convert.toStrArray(notice.getBureauDeptIds()); |
|
|
|
for (String string : strings) { |
|
|
|
Dept dept = deptMapper.selectDeptById(string); |
|
|
|
if (Objects.nonNull(dept)) { |
|
|
|
if (deptNames == null) { |
|
|
|
deptNames = new StringBuilder(""); |
|
|
|
deptNames.append(dept.getDeptName()); |
|
|
|
} else { |
|
|
|
deptNames.append(",").append(dept.getDeptName()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
notice.setBureauDeptNames(deptNames.toString()); |
|
|
|
} |
|
|
|
return noticeMapper.insertNotice(notice); |
|
|
|
} |
|
|
|
|
|
|
|
@ -109,6 +136,23 @@ public class NoticeServiceImpl implements INoticeService |
|
|
|
String busId = IdUtil.fastSimpleUUID(); |
|
|
|
notice.setNoticeId(busId); |
|
|
|
notice.setCreateBy(ShiroUtils.getLoginName()); |
|
|
|
//通过部门id获取部门名称
|
|
|
|
if (StringUtils.isNotEmpty(notice.getBureauDeptIds())) { |
|
|
|
StringBuilder deptNames = null; |
|
|
|
String[] strings = Convert.toStrArray(notice.getBureauDeptIds()); |
|
|
|
for (String string : strings) { |
|
|
|
Dept dept = deptMapper.selectDeptById(string); |
|
|
|
if (Objects.nonNull(dept)) { |
|
|
|
if (deptNames == null) { |
|
|
|
deptNames = new StringBuilder(""); |
|
|
|
deptNames.append(dept.getDeptName()); |
|
|
|
} else { |
|
|
|
deptNames.append(",").append(dept.getDeptName()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
notice.setBureauDeptNames(deptNames.toString()); |
|
|
|
} |
|
|
|
// 上传文件,并在附件表中添加记录
|
|
|
|
if (ObjectUtil.isNotEmpty(files)) { |
|
|
|
for (MultipartFile file : files) { |
|
|
|
@ -122,7 +166,7 @@ public class NoticeServiceImpl implements INoticeService |
|
|
|
|
|
|
|
/** |
|
|
|
* 修改公告 |
|
|
|
* |
|
|
|
* |
|
|
|
* @param notice 公告信息 |
|
|
|
* @return 结果 |
|
|
|
*/ |
|
|
|
@ -130,6 +174,23 @@ public class NoticeServiceImpl implements INoticeService |
|
|
|
public int updateNotice(Notice notice) |
|
|
|
{ |
|
|
|
notice.setUpdateBy(ShiroUtils.getLoginName()); |
|
|
|
//通过部门id获取部门名称
|
|
|
|
if (StringUtils.isNotEmpty(notice.getBureauDeptIds())) { |
|
|
|
StringBuilder deptNames = null; |
|
|
|
String[] strings = Convert.toStrArray(notice.getBureauDeptIds()); |
|
|
|
for (String string : strings) { |
|
|
|
Dept dept = deptMapper.selectDeptById(string); |
|
|
|
if (Objects.nonNull(dept)) { |
|
|
|
if (deptNames == null) { |
|
|
|
deptNames = new StringBuilder(""); |
|
|
|
deptNames.append(dept.getDeptName()); |
|
|
|
} else { |
|
|
|
deptNames.append(",").append(dept.getDeptName()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
notice.setBureauDeptNames(deptNames.toString()); |
|
|
|
} |
|
|
|
return noticeMapper.updateNotice(notice); |
|
|
|
} |
|
|
|
|
|
|
|
@ -143,13 +204,30 @@ public class NoticeServiceImpl implements INoticeService |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
//通过部门id获取部门名称
|
|
|
|
if (StringUtils.isNotEmpty(notice.getBureauDeptIds())) { |
|
|
|
StringBuilder deptNames = null; |
|
|
|
String[] strings = Convert.toStrArray(notice.getBureauDeptIds()); |
|
|
|
for (String string : strings) { |
|
|
|
Dept dept = deptMapper.selectDeptById(string); |
|
|
|
if (Objects.nonNull(dept)) { |
|
|
|
if (deptNames == null) { |
|
|
|
deptNames = new StringBuilder(""); |
|
|
|
deptNames.append(dept.getDeptName()); |
|
|
|
} else { |
|
|
|
deptNames.append(",").append(dept.getDeptName()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
notice.setBureauDeptNames(deptNames.toString()); |
|
|
|
} |
|
|
|
notice.setUpdateBy(ShiroUtils.getLoginName()); |
|
|
|
return noticeMapper.updateNotice(notice); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 删除公告对象 |
|
|
|
* |
|
|
|
* |
|
|
|
* @param ids 需要删除的数据ID |
|
|
|
* @return 结果 |
|
|
|
*/ |
|
|
|
|