消息通知
parent
14fc936df7
commit
4fa04e0324
@ -0,0 +1,194 @@
|
||||
package com.ruoyi.web.controller.ehs;
|
||||
|
||||
import java.util.*;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.github.pagehelper.util.StringUtil;
|
||||
import com.ruoyi.common.constant.Constants;
|
||||
import com.ruoyi.common.core.domain.entity.SysDept;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.system.service.ISysDeptService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.ehsNoticeMessage.domain.EhsNoticeMessage;
|
||||
import com.ruoyi.ehsNoticeMessage.service.IEhsNoticeMessageService;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 内部公告Controller
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2023-12-06
|
||||
*/
|
||||
@Api(tags="内部公告管理")
|
||||
@RestController
|
||||
@RequestMapping("/ehsNoticeMessage/ehsNoticeMessage")
|
||||
public class EhsNoticeMessageController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private IEhsNoticeMessageService ehsNoticeMessageService;
|
||||
@Autowired
|
||||
private ISysDeptService deptService;
|
||||
/**
|
||||
* 查询内部公告列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('ehsNoticeMessage:ehsNoticeMessage:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(EhsNoticeMessage ehsNoticeMessage)
|
||||
{
|
||||
startPage();
|
||||
ehsNoticeMessage.setDeptId(SecurityUtils.getDeptId());
|
||||
ehsNoticeMessage.setStatus("1");
|
||||
ehsNoticeMessage.setFileDeptId(SecurityUtils.getDeptId());
|
||||
List<EhsNoticeMessage> list = ehsNoticeMessageService.selectEhsNoticeMessageList(ehsNoticeMessage);
|
||||
return getDataTable(list);
|
||||
}
|
||||
@PreAuthorize("@ss.hasPermi('ehsNoticeMessage:ehsNoticeMessage:listAdmin')")
|
||||
@GetMapping("/listAdmin")
|
||||
public TableDataInfo listAdmin(EhsNoticeMessage ehsNoticeMessage)
|
||||
{
|
||||
startPage();
|
||||
ehsNoticeMessage.setCreateDeptId(SecurityUtils.getDeptId());
|
||||
List<EhsNoticeMessage> list = ehsNoticeMessageService.selectEhsNoticeMessageListAdmin(ehsNoticeMessage);
|
||||
return getDataTable(list);
|
||||
}
|
||||
/**
|
||||
* 导出内部公告列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('ehsNoticeMessage:ehsNoticeMessage:export')")
|
||||
@Log(title = "内部公告", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, EhsNoticeMessage ehsNoticeMessage)
|
||||
{
|
||||
List<EhsNoticeMessage> list = ehsNoticeMessageService.selectEhsNoticeMessageList(ehsNoticeMessage);
|
||||
ExcelUtil<EhsNoticeMessage> util = new ExcelUtil<EhsNoticeMessage>(EhsNoticeMessage.class);
|
||||
util.exportExcel(response, list, "内部公告数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取内部公告详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('ehsNoticeMessage:ehsNoticeMessage:query')")
|
||||
@GetMapping(value = "/{noticeMessageId}")
|
||||
public AjaxResult getInfo(@PathVariable("noticeMessageId") Long noticeMessageId)
|
||||
{
|
||||
return success(ehsNoticeMessageService.selectEhsNoticeMessageByNoticeMessageId(noticeMessageId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增内部公告
|
||||
*/
|
||||
@ApiOperation("新增内部公告")
|
||||
@PreAuthorize("@ss.hasPermi('ehsNoticeMessage:ehsNoticeMessage:add')")
|
||||
@Log(title = "内部公告", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody EhsNoticeMessage ehsNoticeMessage)
|
||||
{
|
||||
if (ehsNoticeMessage.getAllDept() == 0 && StringUtil.isEmpty(ehsNoticeMessage.getDeptList())) {
|
||||
return error("未选择部门!");
|
||||
} else {
|
||||
ehsNoticeMessage.setStatus("0");
|
||||
ehsNoticeMessage.setCreateUserId(SecurityUtils.getUserId());
|
||||
ehsNoticeMessage.setCreateDeptId(SecurityUtils.getDeptId());
|
||||
if (ehsNoticeMessage.getAllDept() == 1) {
|
||||
List<String> deptList = new ArrayList<>();
|
||||
SysDept dept = new SysDept();
|
||||
dept.setParentId(0L);
|
||||
List<SysDept> depts = deptService.selectAllDeptList(dept);
|
||||
for (SysDept dd : depts) {
|
||||
deptList.add(dd.getDeptId().toString());
|
||||
}
|
||||
ehsNoticeMessage.setDeptList(StringUtils.join(deptList, ","));
|
||||
}
|
||||
return toAjax(ehsNoticeMessageService.save(ehsNoticeMessage));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改内部公告
|
||||
*/
|
||||
@ApiOperation("修改内部公告")
|
||||
@PreAuthorize("@ss.hasPermi('ehsNoticeMessage:ehsNoticeMessage:edit')")
|
||||
@Log(title = "内部公告", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody EhsNoticeMessage ehsNoticeMessage)
|
||||
{
|
||||
if (ehsNoticeMessage.getAllDept() == 0 && StringUtil.isEmpty(ehsNoticeMessage.getDeptList())) {
|
||||
return error("未选择部门!");
|
||||
} else {
|
||||
ehsNoticeMessage.setStatus("0");
|
||||
ehsNoticeMessage.setCreateUserId(SecurityUtils.getUserId());
|
||||
ehsNoticeMessage.setCreateDeptId(SecurityUtils.getDeptId());
|
||||
if (ehsNoticeMessage.getAllDept() == 1) {
|
||||
List<String> deptList = new ArrayList<>();
|
||||
SysDept dept = new SysDept();
|
||||
dept.setParentId(0L);
|
||||
List<SysDept> depts = deptService.selectAllDeptList(dept);
|
||||
for (SysDept dd : depts) {
|
||||
deptList.add(dd.getDeptId().toString());
|
||||
}
|
||||
ehsNoticeMessage.setDeptList(StringUtils.join(deptList, ","));
|
||||
}
|
||||
return toAjax(ehsNoticeMessageService.updateById(ehsNoticeMessage));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除内部公告
|
||||
*/
|
||||
@ApiOperation("删除内部公告")
|
||||
@PreAuthorize("@ss.hasPermi('ehsNoticeMessage:ehsNoticeMessage:remove')")
|
||||
@Log(title = "内部公告", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{noticeMessageIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] noticeMessageIds)
|
||||
{
|
||||
return toAjax(ehsNoticeMessageService.removeByIds(Arrays.asList(noticeMessageIds)));
|
||||
}
|
||||
|
||||
/**
|
||||
*发布
|
||||
*/
|
||||
@ApiOperation("发布公告")
|
||||
@PreAuthorize("@ss.hasPermi('ehsNoticeMessage:ehsNoticeMessage:issueNews')")
|
||||
@Log(title = "发布公告", businessType = BusinessType.UPDATE)
|
||||
@GetMapping("/issueNews")
|
||||
public AjaxResult issueNews( EhsNoticeMessage ehsNoticeMessage)
|
||||
{
|
||||
ehsNoticeMessage.setStatus("1");
|
||||
return toAjax(ehsNoticeMessageService.updateById(ehsNoticeMessage));
|
||||
}
|
||||
|
||||
@ApiOperation("阅读公告")
|
||||
@PreAuthorize("@ss.hasPermi('ehsNoticeMessage:ehsNoticeMessage:detail')")
|
||||
@Log(title = "阅读公告", businessType = BusinessType.UPDATE)
|
||||
@GetMapping(value = "/detail/{noticeMessageId}")
|
||||
public AjaxResult detail(@PathVariable("noticeMessageId") Long noticeMessageId)
|
||||
{
|
||||
EhsNoticeMessage ehsNoticeMessage = ehsNoticeMessageService.selectEhsNoticeMessageByNoticeMessageId(noticeMessageId);
|
||||
EhsNoticeMessage nm = new EhsNoticeMessage();
|
||||
if (StringUtils.isEmpty(ehsNoticeMessage.getReadDeptId()) || ehsNoticeMessage.getReadDeptId().indexOf(SecurityUtils.getDeptId()+ ",") < 0) {
|
||||
nm.setReadDeptId(SecurityUtils.getDeptId() + ",");
|
||||
nm.setNoticeMessageId(noticeMessageId);
|
||||
ehsNoticeMessageService.updateReadCompany(nm);
|
||||
}
|
||||
return success(ehsNoticeMessage);
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package com.ruoyi.ehsNoticeMessage.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.ruoyi.ehsNoticeMessage.domain.EhsNoticeMessage;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 内部公告Mapper接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2023-12-06
|
||||
*/
|
||||
public interface EhsNoticeMessageMapper extends BaseMapper<EhsNoticeMessage> {
|
||||
/**
|
||||
* 查询内部公告
|
||||
*
|
||||
* @param noticeMessageId 内部公告主键
|
||||
* @return 内部公告
|
||||
*/
|
||||
public EhsNoticeMessage selectEhsNoticeMessageByNoticeMessageId(Long noticeMessageId);
|
||||
|
||||
/**
|
||||
* 查询内部公告列表
|
||||
*
|
||||
* @param ehsNoticeMessage 内部公告
|
||||
* @return 内部公告集合
|
||||
*/
|
||||
public List<EhsNoticeMessage> selectEhsNoticeMessageList(EhsNoticeMessage ehsNoticeMessage);
|
||||
|
||||
public List<EhsNoticeMessage> selectEhsNoticeMessageListAdmin(EhsNoticeMessage ehsNoticeMessage);
|
||||
public int updateReadCompany(EhsNoticeMessage ehsNoticeMessage);
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package com.ruoyi.ehsNoticeMessage.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.ruoyi.ehsNoticeMessage.domain.EhsNoticeMessage;
|
||||
|
||||
/**
|
||||
* 内部公告Service接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2023-12-06
|
||||
*/
|
||||
public interface IEhsNoticeMessageService extends IService<EhsNoticeMessage> {
|
||||
|
||||
/**
|
||||
* 查询内部公告
|
||||
*
|
||||
* @param noticeMessageId 内部公告主键
|
||||
* @return 内部公告
|
||||
*/
|
||||
public EhsNoticeMessage selectEhsNoticeMessageByNoticeMessageId(Long noticeMessageId);
|
||||
|
||||
/**
|
||||
* 查询内部公告列表
|
||||
*
|
||||
* @param ehsNoticeMessage 内部公告
|
||||
* @return 内部公告集合
|
||||
*/
|
||||
public List<EhsNoticeMessage> selectEhsNoticeMessageList(EhsNoticeMessage ehsNoticeMessage);
|
||||
|
||||
|
||||
public List<EhsNoticeMessage> selectEhsNoticeMessageListAdmin(EhsNoticeMessage ehsNoticeMessage);
|
||||
public int updateReadCompany(EhsNoticeMessage ehsNoticeMessage);
|
||||
}
|
@ -0,0 +1,79 @@
|
||||
package com.ruoyi.ehsNoticeMessage.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import com.ruoyi.ehsNoticeMessage.mapper.EhsNoticeMessageMapper;
|
||||
import com.ruoyi.ehsNoticeMessage.domain.EhsNoticeMessage;
|
||||
import com.ruoyi.ehsNoticeMessage.service.IEhsNoticeMessageService;
|
||||
|
||||
/**
|
||||
* 内部公告Service业务层处理
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2023-12-06
|
||||
*/
|
||||
@Service
|
||||
public class EhsNoticeMessageServiceImpl extends ServiceImpl<EhsNoticeMessageMapper, EhsNoticeMessage> implements IEhsNoticeMessageService {
|
||||
|
||||
@Autowired
|
||||
private EhsNoticeMessageMapper ehsNoticeMessageMapper;
|
||||
|
||||
/**
|
||||
* 查询内部公告
|
||||
*
|
||||
* @param noticeMessageId 内部公告主键
|
||||
* @return 内部公告
|
||||
*/
|
||||
@Override
|
||||
public EhsNoticeMessage selectEhsNoticeMessageByNoticeMessageId(Long noticeMessageId)
|
||||
{
|
||||
return ehsNoticeMessageMapper.selectEhsNoticeMessageByNoticeMessageId(noticeMessageId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询内部公告列表
|
||||
*
|
||||
* @param ehsNoticeMessage 内部公告
|
||||
* @return 内部公告
|
||||
*/
|
||||
@Override
|
||||
public List<EhsNoticeMessage> selectEhsNoticeMessageList(EhsNoticeMessage ehsNoticeMessage)
|
||||
{
|
||||
return ehsNoticeMessageMapper.selectEhsNoticeMessageList(ehsNoticeMessage);
|
||||
}
|
||||
@Override
|
||||
public List<EhsNoticeMessage> selectEhsNoticeMessageListAdmin(EhsNoticeMessage ehsNoticeMessage)
|
||||
{
|
||||
return ehsNoticeMessageMapper.selectEhsNoticeMessageListAdmin(ehsNoticeMessage);
|
||||
}
|
||||
@Override
|
||||
public int updateReadCompany(EhsNoticeMessage ehsNoticeMessage)
|
||||
{
|
||||
return ehsNoticeMessageMapper.updateReadCompany(ehsNoticeMessage);
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<EhsNoticeMessage> buildQueryWrapper(EhsNoticeMessage query) {
|
||||
Map<String, Object> params = query.getParams();
|
||||
LambdaQueryWrapper<EhsNoticeMessage> lqw = Wrappers.lambdaQuery();
|
||||
lqw.eq(StringUtils.isNotBlank(query.getTitle()), EhsNoticeMessage::getTitle, query.getTitle());
|
||||
lqw.eq(StringUtils.isNotBlank(query.getDisplayContent()), EhsNoticeMessage::getDisplayContent, query.getDisplayContent());
|
||||
lqw.like(StringUtils.isNotBlank(query.getFileName()), EhsNoticeMessage::getFileName, query.getFileName());
|
||||
lqw.eq(StringUtils.isNotBlank(query.getStatus()), EhsNoticeMessage::getStatus, query.getStatus());
|
||||
lqw.eq(StringUtils.isNotBlank(query.getReadDeptId()), EhsNoticeMessage::getReadDeptId, query.getReadDeptId());
|
||||
lqw.eq(query.getMesgType() != null, EhsNoticeMessage::getMesgType, query.getMesgType());
|
||||
lqw.eq(StringUtils.isNotBlank(query.getDeptList()), EhsNoticeMessage::getDeptList, query.getDeptList());
|
||||
lqw.eq(query.getAllDept() != null, EhsNoticeMessage::getAllDept, query.getAllDept());
|
||||
lqw.orderByDesc(EhsNoticeMessage::getCreateTime);
|
||||
lqw.eq(query.getDeptId() != null, EhsNoticeMessage::getDeptId, query.getDeptId());
|
||||
lqw.eq(query.getCreateUserId() != null, EhsNoticeMessage::getCreateUserId, query.getCreateUserId());
|
||||
lqw.eq(query.getUpdateUserId() != null, EhsNoticeMessage::getUpdateUserId, query.getUpdateUserId());
|
||||
return lqw;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package com.ruoyi.ehsNoticeMessageFile.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.ruoyi.ehsNoticeMessageFile.domain.EhsNoticeMessageFile;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 通知公告附件Mapper接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2023-12-07
|
||||
*/
|
||||
public interface EhsNoticeMessageFileMapper extends BaseMapper<EhsNoticeMessageFile> {
|
||||
/**
|
||||
* 查询通知公告附件
|
||||
*
|
||||
* @param id 通知公告附件主键
|
||||
* @return 通知公告附件
|
||||
*/
|
||||
public EhsNoticeMessageFile selectEhsNoticeMessageFileById(String id);
|
||||
|
||||
/**
|
||||
* 查询通知公告附件列表
|
||||
*
|
||||
* @param ehsNoticeMessageFile 通知公告附件
|
||||
* @return 通知公告附件集合
|
||||
*/
|
||||
public List<EhsNoticeMessageFile> selectEhsNoticeMessageFileList(EhsNoticeMessageFile ehsNoticeMessageFile);
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package com.ruoyi.ehsNoticeMessageFile.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.ruoyi.ehsNoticeMessageFile.domain.EhsNoticeMessageFile;
|
||||
|
||||
/**
|
||||
* 通知公告附件Service接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2023-12-07
|
||||
*/
|
||||
public interface IEhsNoticeMessageFileService extends IService<EhsNoticeMessageFile> {
|
||||
|
||||
/**
|
||||
* 查询通知公告附件
|
||||
*
|
||||
* @param id 通知公告附件主键
|
||||
* @return 通知公告附件
|
||||
*/
|
||||
public EhsNoticeMessageFile selectEhsNoticeMessageFileById(String id);
|
||||
|
||||
/**
|
||||
* 查询通知公告附件列表
|
||||
*
|
||||
* @param ehsNoticeMessageFile 通知公告附件
|
||||
* @return 通知公告附件集合
|
||||
*/
|
||||
public List<EhsNoticeMessageFile> selectEhsNoticeMessageFileList(EhsNoticeMessageFile ehsNoticeMessageFile);
|
||||
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
package com.ruoyi.ehsNoticeMessageFile.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import com.ruoyi.ehsNoticeMessageFile.mapper.EhsNoticeMessageFileMapper;
|
||||
import com.ruoyi.ehsNoticeMessageFile.domain.EhsNoticeMessageFile;
|
||||
import com.ruoyi.ehsNoticeMessageFile.service.IEhsNoticeMessageFileService;
|
||||
|
||||
/**
|
||||
* 通知公告附件Service业务层处理
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2023-12-07
|
||||
*/
|
||||
@Service
|
||||
public class EhsNoticeMessageFileServiceImpl extends ServiceImpl<EhsNoticeMessageFileMapper, EhsNoticeMessageFile> implements IEhsNoticeMessageFileService {
|
||||
|
||||
@Autowired
|
||||
private EhsNoticeMessageFileMapper ehsNoticeMessageFileMapper;
|
||||
|
||||
/**
|
||||
* 查询通知公告附件
|
||||
*
|
||||
* @param id 通知公告附件主键
|
||||
* @return 通知公告附件
|
||||
*/
|
||||
@Override
|
||||
public EhsNoticeMessageFile selectEhsNoticeMessageFileById(String id)
|
||||
{
|
||||
return ehsNoticeMessageFileMapper.selectEhsNoticeMessageFileById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询通知公告附件列表
|
||||
*
|
||||
* @param ehsNoticeMessageFile 通知公告附件
|
||||
* @return 通知公告附件
|
||||
*/
|
||||
@Override
|
||||
public List<EhsNoticeMessageFile> selectEhsNoticeMessageFileList(EhsNoticeMessageFile ehsNoticeMessageFile)
|
||||
{
|
||||
return ehsNoticeMessageFileMapper.selectEhsNoticeMessageFileList(ehsNoticeMessageFile);
|
||||
}
|
||||
|
||||
|
||||
private LambdaQueryWrapper<EhsNoticeMessageFile> buildQueryWrapper(EhsNoticeMessageFile query) {
|
||||
Map<String, Object> params = query.getParams();
|
||||
LambdaQueryWrapper<EhsNoticeMessageFile> lqw = Wrappers.lambdaQuery();
|
||||
lqw.like(StringUtils.isNotBlank(query.getFileName()), EhsNoticeMessageFile::getFileName, query.getFileName());
|
||||
lqw.eq(query.getState() != null, EhsNoticeMessageFile::getState, query.getState());
|
||||
lqw.like(StringUtils.isNotBlank(query.getOriginalName()), EhsNoticeMessageFile::getOriginalName, query.getOriginalName());
|
||||
lqw.eq(StringUtils.isNotBlank(query.getFileSize()), EhsNoticeMessageFile::getFileSize, query.getFileSize());
|
||||
lqw.eq(query.getSubmitTime() != null, EhsNoticeMessageFile::getSubmitTime, query.getSubmitTime());
|
||||
lqw.orderByDesc(EhsNoticeMessageFile::getCreateTime);
|
||||
lqw.eq(query.getDeptId() != null, EhsNoticeMessageFile::getDeptId, query.getDeptId());
|
||||
lqw.eq(query.getCreateUserId() != null, EhsNoticeMessageFile::getCreateUserId, query.getCreateUserId());
|
||||
lqw.eq(query.getUpdateUserId() != null, EhsNoticeMessageFile::getUpdateUserId, query.getUpdateUserId());
|
||||
return lqw;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.ehsNoticeMessageFile.mapper.EhsNoticeMessageFileMapper">
|
||||
|
||||
<resultMap type="EhsNoticeMessageFile" id="EhsNoticeMessageFileResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="noticeMessageId" column="notice_message_id" />
|
||||
<result property="fileName" column="file_name" />
|
||||
<result property="state" column="state" />
|
||||
<result property="originalName" column="original_name" />
|
||||
<result property="fileSize" column="file_size" />
|
||||
<result property="submitTime" column="submit_time" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="remark" column="remark" />
|
||||
<result property="deptId" column="dept_id" />
|
||||
<result property="createUserId" column="create_user_id" />
|
||||
<result property="updateUserId" column="update_user_id" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectEhsNoticeMessageFileVo">
|
||||
select id, notice_message_id, file_name, state, original_name, file_size, submit_time, create_by, create_time, update_by, update_time, remark, dept_id, create_user_id, update_user_id from ehs_notice_message_file
|
||||
</sql>
|
||||
|
||||
<select id="selectEhsNoticeMessageFileList" parameterType="EhsNoticeMessageFile" resultMap="EhsNoticeMessageFileResult">
|
||||
<include refid="selectEhsNoticeMessageFileVo"/>
|
||||
<where>
|
||||
<if test="noticeMessageId != null and noticeMessageId != ''"> and notice_message_id = #{noticeMessageId}</if>
|
||||
<if test="fileName != null and fileName != ''"> and file_name like concat('%', #{fileName}, '%')</if>
|
||||
<if test="state != null "> and state = #{state}</if>
|
||||
<if test="originalName != null and originalName != ''"> and original_name like concat('%', #{originalName}, '%')</if>
|
||||
<if test="fileSize != null and fileSize != ''"> and file_size = #{fileSize}</if>
|
||||
<if test="submitTime != null "> and submit_time = #{submitTime}</if>
|
||||
<if test="deptId != null "> and dept_id = #{deptId}</if>
|
||||
<if test="createUserId != null "> and create_user_id = #{createUserId}</if>
|
||||
<if test="updateUserId != null "> and update_user_id = #{updateUserId}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectEhsNoticeMessageFileById" parameterType="String" resultMap="EhsNoticeMessageFileResult">
|
||||
<include refid="selectEhsNoticeMessageFileVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
|
||||
</mapper>
|
@ -0,0 +1,97 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.ehsNoticeMessage.mapper.EhsNoticeMessageMapper">
|
||||
|
||||
<resultMap type="EhsNoticeMessage" id="EhsNoticeMessageResult">
|
||||
<result property="noticeMessageId" column="notice_message_id" />
|
||||
<result property="title" column="title" />
|
||||
<result property="displayContent" column="display_content" />
|
||||
<result property="fileName" column="file_name" />
|
||||
<result property="status" column="status" />
|
||||
<result property="readDeptId" column="read_dept_id" />
|
||||
<result property="mesgType" column="mesg_type" />
|
||||
<result property="deptList" column="dept_list" />
|
||||
<result property="allDept" column="all_dept" />
|
||||
<result property="createDeptId" column="create_dept_id" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="remark" column="remark" />
|
||||
<result property="deptId" column="dept_id" />
|
||||
<result property="createUserId" column="create_user_id" />
|
||||
<result property="updateUserId" column="update_user_id" />
|
||||
<result property="fileCount" column="file_count" />
|
||||
<result property="fileState" column="file_state" />
|
||||
<result property="fileDeptId" column="file_dept_id" />
|
||||
<result property="isRead" column="is_read" />
|
||||
<result property="messageFileId" column="message_file_id" />
|
||||
<result property="originalName" column="original_name" />
|
||||
<result property="noticeMessageFileId" column="notice_message_fele_id" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectEhsNoticeMessageVo">
|
||||
select notice_message_id, title, display_content, file_name, status, read_dept_id, mesg_type, dept_list, all_dept, create_dept_id, create_by, create_time, update_by, update_time, remark, dept_id, create_user_id, update_user_id from ehs_notice_message
|
||||
</sql>
|
||||
|
||||
<select id="selectEhsNoticeMessageList" parameterType="EhsNoticeMessage" resultMap="EhsNoticeMessageResult">
|
||||
select m.notice_message_id, m.create_user_id, m.create_time, m.dept_id,m.title, m.display_content, m.status,d.dept_name dept_name
|
||||
,FIND_IN_SET(#{deptId}, m.read_dept_id ) is_read,m.mesg_type,m.read_dept_id,m.all_dept,
|
||||
(select f.id from ehs_notice_message_file f where m.notice_message_id = f.notice_message_id and f.dept_ID =#{fileDeptId} ) AS message_file_id,
|
||||
(select f.file_name from ehs_notice_message_file f where m.notice_message_id = f.notice_message_id and f.dept_ID =#{fileDeptId}) file_name,
|
||||
IFNULL((select IFNULL(f.state,0) from ehs_notice_message_file f where m.notice_message_id = f.notice_message_id and f.dept_ID =#{fileDeptId}),0) file_state,
|
||||
(select f.original_name from ehs_notice_message_file f where m.notice_message_id = f.notice_message_id and f.dept_ID =#{fileDeptId}) original_name,
|
||||
(select f.file_size from ehs_notice_message_file f where m.notice_message_id = f.notice_message_id and f.dept_ID =#{fileDeptId}) file_size,
|
||||
(select f.dept_id from ehs_notice_message_file f where m.notice_message_id = f.notice_message_id and f.dept_ID =#{fileDeptId}) file_dept_id
|
||||
from ehs_notice_message m
|
||||
left join sys_user e on e.user_id = m.CREATE_USER_ID
|
||||
left join sys_dept d on m.dept_id=d.dept_id and d.parent_id!=0
|
||||
<where>
|
||||
<if test="title != null and title != '' "> and m.title like '%${title}%'</if>
|
||||
<if test="displayContent != null and displayContent != '' "> and m.display_content = #{displayContent}</if>
|
||||
<!--<if test="createUserName != null and createUserName != '' "> and e.name like '%${createUserName}%'</if>-->
|
||||
<if test="status != null and status != '' "> and m.status = #{status}</if>
|
||||
<if test="deptId != null and deptId != '' "> and (FIND_IN_SET(#{deptId}, m.dept_list) or m.all_dept=1) </if>
|
||||
<if test="mesgType != null and mesgType != '' "> and m.mesg_type = #{mesgType}</if>
|
||||
<if test='isRead =="0" '> and FIND_IN_SET(#{deptId}, m.read_dept_id )=0</if>
|
||||
<if test="fileState != null and fileState != '' "> and f.state = #{fileState}</if>
|
||||
<if test="noticeMessageId != null and noticeMessageId != '' "> and f.id = #{noticeMessageId}</if>
|
||||
|
||||
</where>
|
||||
</select>
|
||||
<select id="selectEhsNoticeMessageListAdmin" parameterType="EhsNoticeMessage" resultMap="EhsNoticeMessageResult">
|
||||
SELECT m.notice_message_id, m.create_user_id, m.create_time, m.dept_id,
|
||||
m.title, m.display_content, m.STATUS, m.dept_list, GROUP_CONCAT( ft.dept_name SEPARATOR ';' ) dept_name,
|
||||
m.mesg_type, m.read_dept_id, m.all_dept,
|
||||
( SELECT count( 1 ) FROM ehs_notice_message_file f WHERE f.notice_message_id = m.notice_message_id ) file_count
|
||||
FROM ehs_notice_message m
|
||||
LEFT JOIN sys_user e ON e.user_id = m.CREATE_USER_ID
|
||||
LEFT JOIN sys_dept ft ON FIND_IN_SET( ft.DEPT_ID, m.dept_list )
|
||||
<where>
|
||||
<if test="title != null and title != '' "> and m.title like '%${title}%'</if>
|
||||
<if test="displayContent != null and displayContent != '' "> and m.display_content = #{displayContent}</if>
|
||||
<!--<if test="createUserName != null and createUserName != '' "> and e.name like '%${createUserName}%'</if>-->
|
||||
<if test="status != null and status != '' "> and m.status = #{status}</if>
|
||||
<if test="deptList != null and companyId != '' "> and FIND_IN_SET(#{deptList}, m.dept_list) </if>
|
||||
<if test="mesgType != null and mesgType != '' "> and m.mesg_type = #{mesgType}</if>
|
||||
<if test="createDeptId != null and createDeptId != '' "> and m.create_dept_id = #{createDeptId} </if>
|
||||
</where>
|
||||
GROUP BY m.create_time desc
|
||||
</select>
|
||||
<select id="selectEhsNoticeMessageByNoticeMessageId" parameterType="Long" resultMap="EhsNoticeMessageResult">
|
||||
<include refid="selectEhsNoticeMessageVo"/>
|
||||
where notice_message_id = #{noticeMessageId}
|
||||
</select>
|
||||
|
||||
<update id="updateReadCompany" parameterType="EhsNoticeMessage">
|
||||
update ehs_notice_message
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="readDeptId != null and readDeptId != '' ">read_Dept_id =CONCAT(read_Dept_id,#{readDeptId}) </if>
|
||||
</trim>
|
||||
where notice_message_id = #{noticeMessageId}
|
||||
</update>
|
||||
|
||||
|
||||
</mapper>
|
@ -0,0 +1,65 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
// 查询内部公告列表
|
||||
export function listEhsNoticeMessage(query) {
|
||||
return request({
|
||||
url: '/ehsNoticeMessage/ehsNoticeMessage/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
export function listEhsNoticeMessageAdmin(query) {
|
||||
return request({
|
||||
url: '/ehsNoticeMessage/ehsNoticeMessage/listAdmin',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
// 查询内部公告详细
|
||||
export function getEhsNoticeMessage(noticeMessageId) {
|
||||
return request({
|
||||
url: '/ehsNoticeMessage/ehsNoticeMessage/' + noticeMessageId,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 新增内部公告
|
||||
export function addEhsNoticeMessage(data) {
|
||||
return request({
|
||||
url: '/ehsNoticeMessage/ehsNoticeMessage',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 修改内部公告
|
||||
export function updateEhsNoticeMessage(data) {
|
||||
return request({
|
||||
url: '/ehsNoticeMessage/ehsNoticeMessage',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 删除内部公告
|
||||
export function delEhsNoticeMessage(noticeMessageId) {
|
||||
return request({
|
||||
url: '/ehsNoticeMessage/ehsNoticeMessage/' + noticeMessageId,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
//发布
|
||||
export function issueNews(query) {
|
||||
return request({
|
||||
url: '/ehsNoticeMessage/ehsNoticeMessage/issueNews',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
// 阅读
|
||||
export function detailEhsNoticeMessage(noticeMessageId) {
|
||||
return request({
|
||||
url: '/ehsNoticeMessage/ehsNoticeMessage/detail/' + noticeMessageId,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
// 查询通知公告附件列表
|
||||
export function listEhsNoticeMessageFile(query) {
|
||||
return request({
|
||||
url: '/ehsNoticeMessageFile/ehsNoticeMessageFile/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 查询通知公告附件详细
|
||||
export function getEhsNoticeMessageFile(id) {
|
||||
return request({
|
||||
url: '/ehsNoticeMessageFile/ehsNoticeMessageFile/' + id,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 新增通知公告附件
|
||||
export function addEhsNoticeMessageFile(data) {
|
||||
return request({
|
||||
url: '/ehsNoticeMessageFile/ehsNoticeMessageFile',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 修改通知公告附件
|
||||
export function updateEhsNoticeMessageFile(data) {
|
||||
return request({
|
||||
url: '/ehsNoticeMessageFile/ehsNoticeMessageFile',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 删除通知公告附件
|
||||
export function delEhsNoticeMessageFile(id) {
|
||||
return request({
|
||||
url: '/ehsNoticeMessageFile/ehsNoticeMessageFile/' + id,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
|
||||
// 文件上传列表
|
||||
export function listFileEhsNoticeMessageFile(query) {
|
||||
return request({
|
||||
url: '/ehsNoticeMessageFile/ehsNoticeMessageFile/listFile',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
@ -0,0 +1,216 @@
|
||||
<template>
|
||||
<div class="upload-file">
|
||||
<el-upload
|
||||
multiple
|
||||
:action="uploadFileUrl"
|
||||
:before-upload="handleBeforeUpload"
|
||||
:file-list="fileList"
|
||||
:limit="limit"
|
||||
:on-error="handleUploadError"
|
||||
:on-exceed="handleExceed"
|
||||
:on-success="handleUploadSuccess"
|
||||
:show-file-list="false"
|
||||
:headers="headers"
|
||||
class="upload-file-uploader"
|
||||
ref="fileUpload"
|
||||
>
|
||||
<!-- 上传按钮 -->
|
||||
<el-button size="mini" type="primary">选取文件</el-button>
|
||||
<!-- 上传提示 -->
|
||||
<div class="el-upload__tip" slot="tip" v-if="showTip">
|
||||
请上传
|
||||
<template v-if="fileSize"> 大小不超过 <b style="color: #f56c6c">{{ fileSize }}MB</b> </template>
|
||||
<template v-if="fileType"> 格式为 <b style="color: #f56c6c">{{ fileType.join("/") }}</b> </template>
|
||||
的文件
|
||||
</div>
|
||||
</el-upload>
|
||||
|
||||
<!-- 文件列表 -->
|
||||
<transition-group class="upload-file-list el-upload-list el-upload-list--text" name="el-fade-in-linear" tag="ul">
|
||||
<li :key="file.url" class="el-upload-list__item ele-upload-list__item-content" v-for="(file, index) in fileList">
|
||||
<el-link :href="`${baseUrl}${file.url}`" :underline="false" target="_blank">
|
||||
<span class="el-icon-document"> {{ getFileName(file.name) }} </span>
|
||||
</el-link>
|
||||
<div class="ele-upload-list__item-content-action">
|
||||
<el-link :underline="false" @click="handleDelete(index)" type="danger">删除</el-link>
|
||||
</div>
|
||||
</li>
|
||||
</transition-group>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getToken } from "@/utils/auth";
|
||||
|
||||
export default {
|
||||
name: "FileUpload",
|
||||
props: {
|
||||
// 值
|
||||
value: [String, Object, Array],
|
||||
// 数量限制
|
||||
limit: {
|
||||
type: Number,
|
||||
default: 5,
|
||||
},
|
||||
// 大小限制(MB)
|
||||
fileSize: {
|
||||
type: Number,
|
||||
default: 5,
|
||||
},
|
||||
// 文件类型, 例如['png', 'jpg', 'jpeg']
|
||||
fileType: {
|
||||
type: Array,
|
||||
default: () => ["doc", "xls", "ppt", "txt", "pdf"],
|
||||
},
|
||||
// 是否显示提示
|
||||
isShowTip: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
number: 0,
|
||||
uploadList: [],
|
||||
baseUrl: process.env.VUE_APP_BASE_API,
|
||||
uploadFileUrl: process.env.VUE_APP_BASE_API + "/common/upload", // 上传文件服务器地址
|
||||
headers: {
|
||||
Authorization: "Bearer " + getToken(),
|
||||
},
|
||||
fileList: [],
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
value: {
|
||||
handler(val) {
|
||||
if (val) {
|
||||
let temp = 1;
|
||||
// 首先将值转为数组
|
||||
const list = Array.isArray(val) ? val : this.value.split(',');
|
||||
// 然后将数组转为对象数组
|
||||
this.fileList = list.map(item => {
|
||||
if (typeof item === "string") {
|
||||
item = { name: item, url: item };
|
||||
}
|
||||
item.uid = item.uid || new Date().getTime() + temp++;
|
||||
return item;
|
||||
});
|
||||
} else {
|
||||
this.fileList = [];
|
||||
return [];
|
||||
}
|
||||
},
|
||||
deep: true,
|
||||
immediate: true
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
// 是否显示提示
|
||||
showTip() {
|
||||
return this.isShowTip && (this.fileType || this.fileSize);
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
// 上传前校检格式和大小
|
||||
handleBeforeUpload(file) {
|
||||
// 校检文件类型
|
||||
if (this.fileType) {
|
||||
const fileName = file.name.split('.');
|
||||
const fileExt = fileName[fileName.length - 1];
|
||||
const isTypeOk = this.fileType.indexOf(fileExt) >= 0;
|
||||
if (!isTypeOk) {
|
||||
this.$modal.msgError(`文件格式不正确, 请上传${this.fileType.join("/")}格式文件!`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// 校检文件大小
|
||||
if (this.fileSize) {
|
||||
const isLt = file.size / 1024 / 1024 < this.fileSize;
|
||||
if (!isLt) {
|
||||
this.$modal.msgError(`上传文件大小不能超过 ${this.fileSize} MB!`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
this.$modal.loading("正在上传文件,请稍候...");
|
||||
this.number++;
|
||||
return true;
|
||||
},
|
||||
// 文件个数超出
|
||||
handleExceed() {
|
||||
this.$modal.msgError(`上传文件数量不能超过 ${this.limit} 个!`);
|
||||
},
|
||||
// 上传失败
|
||||
handleUploadError(err) {
|
||||
this.$modal.msgError("上传文件失败,请重试");
|
||||
this.$modal.closeLoading();
|
||||
},
|
||||
// 上传成功回调
|
||||
handleUploadSuccess(res, file) {
|
||||
if (res.code === 200) {
|
||||
this.uploadList.push({ name: res.fileName, url: res.fileName });
|
||||
this.uploadedSuccessfully();
|
||||
} else {
|
||||
this.number--;
|
||||
this.$modal.closeLoading();
|
||||
this.$modal.msgError(res.msg);
|
||||
this.$refs.fileUpload.handleRemove(file);
|
||||
this.uploadedSuccessfully();
|
||||
}
|
||||
},
|
||||
// 删除文件
|
||||
handleDelete(index) {
|
||||
this.fileList.splice(index, 1);
|
||||
this.$emit("input", this.listToString(this.fileList));
|
||||
},
|
||||
// 上传结束处理
|
||||
uploadedSuccessfully() {
|
||||
if (this.number > 0 && this.uploadList.length === this.number) {
|
||||
this.fileList = this.fileList.concat(this.uploadList);
|
||||
this.uploadList = [];
|
||||
this.number = 0;
|
||||
this.$emit("input", this.listToString(this.fileList));
|
||||
this.$modal.closeLoading();
|
||||
}
|
||||
},
|
||||
// 获取文件名称
|
||||
getFileName(name) {
|
||||
// 如果是url那么取最后的名字 如果不是直接返回
|
||||
if (name.lastIndexOf("/") > -1) {
|
||||
return name.slice(name.lastIndexOf("/") + 1);
|
||||
} else {
|
||||
return name;
|
||||
}
|
||||
},
|
||||
// 对象转成指定字符串分隔
|
||||
listToString(list, separator) {
|
||||
let strs = "";
|
||||
separator = separator || ",";
|
||||
for (let i in list) {
|
||||
strs += list[i].url + separator;
|
||||
}
|
||||
return strs != '' ? strs.substr(0, strs.length - 1) : '';
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.upload-file-uploader {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
.upload-file-list .el-upload-list__item {
|
||||
border: 1px solid #e4e7ed;
|
||||
line-height: 2;
|
||||
margin-bottom: 10px;
|
||||
position: relative;
|
||||
}
|
||||
.upload-file-list .ele-upload-list__item-content {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
color: inherit;
|
||||
}
|
||||
.ele-upload-list__item-content-action .el-link {
|
||||
margin-right: 10px;
|
||||
}
|
||||
</style>
|
Loading…
Reference in New Issue