通知公告更改
parent
ec9c972b21
commit
4bcf9fcbe7
|
@ -0,0 +1,112 @@
|
|||
package com.muyu.system.controller;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.muyu.system.domain.resp.AsUserDeotNumResponse;
|
||||
import com.muyu.system.service.IAsUserDeptService;
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.utils.poi.ExcelUtil;
|
||||
import com.muyu.common.core.web.controller.BaseController;
|
||||
import com.muyu.common.log.annotation.Log;
|
||||
import com.muyu.common.log.enums.BusinessType;
|
||||
import com.muyu.common.security.annotation.RequiresPermissions;
|
||||
import com.muyu.system.domain.AsUserDept;
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 用户和公告的中间Controller
|
||||
*
|
||||
* @author wan
|
||||
* @date 2024-04-14
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/userDept")
|
||||
public class AsUserDeptController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private IAsUserDeptService asUserDeptService;
|
||||
|
||||
/**
|
||||
* 查询【请填写功能名称】列表
|
||||
*/
|
||||
@RequiresPermissions("system:dept:list")
|
||||
@PostMapping("/list")
|
||||
public Result<TableDataInfo<AsUserDept>> list(AsUserDept asUserDept)
|
||||
{
|
||||
startPage();
|
||||
List<AsUserDept> list = asUserDeptService.selectAsUserDeptList(asUserDept);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
@GetMapping("/UpdateAsUserDept")
|
||||
public Result list(@RequestParam("id") Long id)
|
||||
{
|
||||
return asUserDeptService.updateAsUserDeptRead(id);
|
||||
}
|
||||
|
||||
@GetMapping("/GetNum")
|
||||
public Result<AsUserDeotNumResponse> getNum(@RequestParam("noticeId") Long noticeId)
|
||||
{
|
||||
return asUserDeptService.getNum(noticeId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出【请填写功能名称】列表
|
||||
*/
|
||||
@RequiresPermissions("system:dept:export")
|
||||
@Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, AsUserDept asUserDept)
|
||||
{
|
||||
List<AsUserDept> list = asUserDeptService.selectAsUserDeptList(asUserDept);
|
||||
ExcelUtil<AsUserDept> util = new ExcelUtil<AsUserDept>(AsUserDept.class);
|
||||
util.exportExcel(response, list, "【请填写功能名称】数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取【请填写功能名称】详细信息
|
||||
*/
|
||||
@RequiresPermissions("system:dept:query")
|
||||
@PostMapping(value = "/{id}")
|
||||
public Result getInfo(@PathVariable("id") Long id)
|
||||
{
|
||||
return success(asUserDeptService.selectAsUserDeptById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增【请填写功能名称】
|
||||
*/
|
||||
@RequiresPermissions("system:dept:add")
|
||||
@Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public Result add(@RequestBody AsUserDept asUserDept)
|
||||
{
|
||||
return toAjax(asUserDeptService.insertAsUserDept(asUserDept));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改【请填写功能名称】
|
||||
*/
|
||||
@RequiresPermissions("system:dept:edit")
|
||||
@Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public Result edit(@RequestBody AsUserDept asUserDept)
|
||||
{
|
||||
return toAjax(asUserDeptService.updateAsUserDept(asUserDept));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除【请填写功能名称】
|
||||
*/
|
||||
@RequiresPermissions("system:dept:remove")
|
||||
@Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public Result remove(@PathVariable Long[] ids)
|
||||
{
|
||||
return toAjax(asUserDeptService.deleteAsUserDeptByIds(ids));
|
||||
}
|
||||
}
|
|
@ -8,6 +8,8 @@ import com.muyu.common.log.enums.BusinessType;
|
|||
import com.muyu.common.security.annotation.RequiresPermissions;
|
||||
import com.muyu.common.security.utils.SecurityUtils;
|
||||
import com.muyu.system.domain.SysNotice;
|
||||
import com.muyu.system.domain.req.SysNoticeRequest;
|
||||
import com.muyu.system.domain.resp.SysNoticeResponse;
|
||||
import com.muyu.system.service.SysNoticeService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
@ -37,6 +39,12 @@ public class
|
|||
return getDataTable(list);
|
||||
}
|
||||
|
||||
@PostMapping("/GetNoticeList")
|
||||
public Result<List<SysNoticeResponse>> getNoticeList (@RequestBody SysNoticeRequest sysNoticeRequest) {
|
||||
return noticeService.getNoticeList(sysNoticeRequest);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据通知公告编号获取详细信息
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
package com.muyu.system.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.muyu.common.core.annotation.Excel;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* @ClassName AsUserDept
|
||||
* @Description 描述
|
||||
* @Author annan.Wang
|
||||
* @Date 2024/4/14 9:11
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class AsUserDept extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** $column.columnComment */
|
||||
private Long id;
|
||||
|
||||
/** $column.columnComment */
|
||||
@Excel(name = "用户ID")
|
||||
private Long userId;
|
||||
|
||||
/** $column.columnComment */
|
||||
@Excel(name = "公告ID")
|
||||
private Long noticeId;
|
||||
|
||||
/** $column.columnComment */
|
||||
@Excel(name = "是否已读")
|
||||
private String isRead;
|
||||
}
|
|
@ -12,6 +12,7 @@ import org.apache.commons.lang3.builder.ToStringStyle;
|
|||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 通知公告表 sys_notice
|
||||
|
@ -51,6 +52,12 @@ public class SysNotice extends BaseEntity {
|
|||
*/
|
||||
private String status;
|
||||
|
||||
/** 部门ID */
|
||||
private List<List<Long>> sectionList;
|
||||
|
||||
/** 用户ID集合 */
|
||||
private List<Long> personnelList;
|
||||
|
||||
public Long getNoticeId () {
|
||||
return noticeId;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
package com.muyu.system.domain.req;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* @ClassName SysNoticeRequest
|
||||
* @Description 描述
|
||||
* @Author annan.Wang
|
||||
* @Date 2024/4/14 9:19
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class SysNoticeRequest {
|
||||
private Long noticeId;
|
||||
private Long userId;
|
||||
private String noticeType;
|
||||
private String isRead;
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package com.muyu.system.domain.resp;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* @ClassName AsUserDeotNumResponse
|
||||
* @Description 描述
|
||||
* @Author annan.Wang
|
||||
* @Date 2024/4/14 9:26
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class AsUserDeotNumResponse {
|
||||
private Long num;
|
||||
private Long readNum;
|
||||
private Long noReadNum;
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package com.muyu.system.domain.resp;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @ClassName SysNoticeResponse
|
||||
* @Description 描述
|
||||
* @Author annan.Wang
|
||||
* @Date 2024/4/14 9:22
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class SysNoticeResponse {
|
||||
private Date createTime;
|
||||
private String createBy;
|
||||
private String noticeType;
|
||||
private String isRead;
|
||||
private String notceTitle;
|
||||
private String noticeContent;
|
||||
private Long noticeId;
|
||||
private Long id;
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
package com.muyu.system.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.muyu.system.domain.AsUserDept;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 【请填写功能名称】Mapper接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-04-13
|
||||
*/
|
||||
public interface AsUserDeptMapper
|
||||
{
|
||||
/**
|
||||
* 查询【请填写功能名称】
|
||||
*
|
||||
* @param id 【请填写功能名称】主键
|
||||
* @return 【请填写功能名称】
|
||||
*/
|
||||
public AsUserDept selectAsUserDeptById(Long id);
|
||||
|
||||
/**
|
||||
* 查询【请填写功能名称】列表
|
||||
*
|
||||
* @param asUserDept 【请填写功能名称】
|
||||
* @return 【请填写功能名称】集合
|
||||
*/
|
||||
public List<AsUserDept> selectAsUserDeptList(AsUserDept asUserDept);
|
||||
|
||||
/**
|
||||
* 新增【请填写功能名称】
|
||||
*
|
||||
* @param asUserDept 【请填写功能名称】
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertAsUserDept(AsUserDept asUserDept);
|
||||
public int insertBachAsUserDept(@Param("asUserDepts") List<AsUserDept> asUserDepts);
|
||||
|
||||
/**
|
||||
* 修改【请填写功能名称】
|
||||
*
|
||||
* @param asUserDept 【请填写功能名称】
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateAsUserDept(AsUserDept asUserDept);
|
||||
|
||||
/**
|
||||
* 删除【请填写功能名称】
|
||||
*
|
||||
* @param id 【请填写功能名称】主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteAsUserDeptById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除【请填写功能名称】
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteAsUserDeptByIds(Long[] ids);
|
||||
|
||||
void updateAsUserDeptRead(@Param("id") Long id);
|
||||
Long selectAsUserDeptNum(@Param("noticeId") Long noticeId);
|
||||
Long selectAsUserDeptReadNum(@Param("noticeId") Long noticeId);
|
||||
}
|
|
@ -2,6 +2,8 @@ package com.muyu.system.mapper;
|
|||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.system.domain.SysNotice;
|
||||
import com.muyu.system.domain.req.SysNoticeRequest;
|
||||
import com.muyu.system.domain.resp.SysNoticeResponse;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -64,4 +66,9 @@ public interface SysNoticeMapper extends BaseMapper<SysNotice> {
|
|||
* @return 结果
|
||||
*/
|
||||
public int deleteNoticeByIds (Long[] noticeIds);
|
||||
|
||||
List<SysNoticeResponse> getNoticeList(SysNoticeRequest sysNoticeRequest);
|
||||
|
||||
List<Long> selectUser();
|
||||
|
||||
}
|
||||
|
|
|
@ -139,4 +139,6 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
|
|||
* @return 结果
|
||||
*/
|
||||
public SysUser checkEmailUnique (String email);
|
||||
|
||||
List<Long> selectDtptUser(@Param("sectionIds") List<Long> sectionIds);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
package com.muyu.system.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.system.domain.AsUserDept;
|
||||
import com.muyu.system.domain.resp.AsUserDeotNumResponse;
|
||||
|
||||
/**
|
||||
* 【请填写功能名称】Service接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-04-13
|
||||
*/
|
||||
public interface IAsUserDeptService
|
||||
{
|
||||
/**
|
||||
* 查询【请填写功能名称】
|
||||
*
|
||||
* @param id 【请填写功能名称】主键
|
||||
* @return 【请填写功能名称】
|
||||
*/
|
||||
public AsUserDept selectAsUserDeptById(Long id);
|
||||
|
||||
/**
|
||||
* 查询【请填写功能名称】列表
|
||||
*
|
||||
* @param asUserDept 【请填写功能名称】
|
||||
* @return 【请填写功能名称】集合
|
||||
*/
|
||||
public List<AsUserDept> selectAsUserDeptList(AsUserDept asUserDept);
|
||||
|
||||
/**
|
||||
* 新增【请填写功能名称】
|
||||
*
|
||||
* @param asUserDept 【请填写功能名称】
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertAsUserDept(AsUserDept asUserDept);
|
||||
|
||||
/**
|
||||
* 修改【请填写功能名称】
|
||||
*
|
||||
* @param asUserDept 【请填写功能名称】
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateAsUserDept(AsUserDept asUserDept);
|
||||
|
||||
/**
|
||||
* 批量删除【请填写功能名称】
|
||||
*
|
||||
* @param ids 需要删除的【请填写功能名称】主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteAsUserDeptByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 删除【请填写功能名称】信息
|
||||
*
|
||||
* @param id 【请填写功能名称】主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteAsUserDeptById(Long id);
|
||||
|
||||
Result updateAsUserDeptRead(Long id);
|
||||
|
||||
Result<AsUserDeotNumResponse> getNum(Long noticeId);
|
||||
}
|
|
@ -1,7 +1,10 @@
|
|||
package com.muyu.system.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.system.domain.SysNotice;
|
||||
import com.muyu.system.domain.req.SysNoticeRequest;
|
||||
import com.muyu.system.domain.resp.SysNoticeResponse;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -64,4 +67,6 @@ public interface SysNoticeService extends IService<SysNotice> {
|
|||
* @return 结果
|
||||
*/
|
||||
public int deleteNoticeByIds (Long[] noticeIds);
|
||||
|
||||
Result<List<SysNoticeResponse>> getNoticeList(SysNoticeRequest sysNoticeRequest);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,119 @@
|
|||
package com.muyu.system.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.utils.DateUtils;
|
||||
import com.muyu.system.domain.resp.AsUserDeotNumResponse;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.muyu.system.mapper.AsUserDeptMapper;
|
||||
import com.muyu.system.domain.AsUserDept;
|
||||
import com.muyu.system.service.IAsUserDeptService;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* 【请填写功能名称】Service业务层处理
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-04-13
|
||||
*/
|
||||
@Service
|
||||
public class AsUserDeptServiceImpl implements IAsUserDeptService
|
||||
{
|
||||
@Autowired
|
||||
private AsUserDeptMapper asUserDeptMapper;
|
||||
|
||||
/**
|
||||
* 查询【请填写功能名称】
|
||||
*
|
||||
* @param id 【请填写功能名称】主键
|
||||
* @return 【请填写功能名称】
|
||||
*/
|
||||
@Override
|
||||
public AsUserDept selectAsUserDeptById(Long id)
|
||||
{
|
||||
return asUserDeptMapper.selectAsUserDeptById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询【请填写功能名称】列表
|
||||
*
|
||||
* @param asUserDept 【请填写功能名称】
|
||||
* @return 【请填写功能名称】
|
||||
*/
|
||||
@Override
|
||||
public List<AsUserDept> selectAsUserDeptList(AsUserDept asUserDept)
|
||||
{
|
||||
return asUserDeptMapper.selectAsUserDeptList(asUserDept);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增【请填写功能名称】
|
||||
*
|
||||
* @param asUserDept 【请填写功能名称】
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertAsUserDept(AsUserDept asUserDept)
|
||||
{
|
||||
asUserDept.setCreateTime(DateUtils.getNowDate());
|
||||
return asUserDeptMapper.insertAsUserDept(asUserDept);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改【请填写功能名称】
|
||||
*
|
||||
* @param asUserDept 【请填写功能名称】
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateAsUserDept(AsUserDept asUserDept)
|
||||
{
|
||||
asUserDept.setUpdateTime(DateUtils.getNowDate());
|
||||
return asUserDeptMapper.updateAsUserDept(asUserDept);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除【请填写功能名称】
|
||||
*
|
||||
* @param ids 需要删除的【请填写功能名称】主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteAsUserDeptByIds(Long[] ids)
|
||||
{
|
||||
return asUserDeptMapper.deleteAsUserDeptByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除【请填写功能名称】信息
|
||||
*
|
||||
* @param id 【请填写功能名称】主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteAsUserDeptById(Long id)
|
||||
{
|
||||
return asUserDeptMapper.deleteAsUserDeptById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public Result updateAsUserDeptRead(Long id) {
|
||||
asUserDeptMapper.updateAsUserDeptRead(id);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<AsUserDeotNumResponse> getNum(Long noticeId) {
|
||||
Long num = asUserDeptMapper.selectAsUserDeptNum(noticeId);
|
||||
Long readNum = asUserDeptMapper.selectAsUserDeptReadNum(noticeId);
|
||||
long noReadNum = num-readNum;
|
||||
return Result.success(AsUserDeotNumResponse.builder()
|
||||
.num(num)
|
||||
.readNum(readNum)
|
||||
.noReadNum(noReadNum)
|
||||
.build());
|
||||
}
|
||||
}
|
|
@ -15,7 +15,6 @@ import com.muyu.system.mapper.SysMenuMapper;
|
|||
import com.muyu.system.mapper.SysRoleMapper;
|
||||
import com.muyu.system.mapper.SysRoleMenuMapper;
|
||||
import com.muyu.system.service.SysMenuService;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
@ -52,24 +51,8 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|||
return selectMenuList(new SysMenu(), userId);
|
||||
}
|
||||
|
||||
public List<SysMenu> selectSysChdMenuList(List<SysMenu> menuList) {
|
||||
public List<SysMenu> selectSysMenuList(List<SysMenu> menuList){
|
||||
List<Long> longs = menuList.stream()
|
||||
.map(menu -> menu.getMenuId())
|
||||
.toList();
|
||||
List<SysMenu> sysMenus = menuMapper.selectSysChdMenuList(longs);
|
||||
if (sysMenus != null && sysMenus.size() != 0) {
|
||||
List<SysMenu> sysMenus1 = selectSysMenuList(sysMenus);
|
||||
if (sysMenus1 != null) {
|
||||
sysMenus.addAll(sysMenus1);
|
||||
}
|
||||
}else {
|
||||
return null;
|
||||
}
|
||||
return sysMenus;
|
||||
}
|
||||
|
||||
public List<SysMenu> selectSysMenuList(List<SysMenu> menus){
|
||||
List<Long> longs = menus.stream()
|
||||
.map(menu -> menu.getParentId())
|
||||
.filter(parentId -> parentId != 0)
|
||||
.distinct()
|
||||
|
@ -85,6 +68,28 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|||
return sysMenus;
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归方式查询菜单所有的子级菜单集合
|
||||
* @param menuList 菜单信息集合
|
||||
* @return List<SysMenu> 所有子级菜单集合
|
||||
*/
|
||||
public List<SysMenu> selectSysChdMenuList(List<SysMenu> menuList){
|
||||
//将菜单信息
|
||||
List<Long> longs = menuList.stream()
|
||||
.map(menu -> menu.getMenuId())
|
||||
.toList();
|
||||
List<SysMenu> sysMenus = menuMapper.selectSysChdMenuList(longs);
|
||||
if (sysMenus!=null && sysMenus.size()!=0){
|
||||
List<SysMenu> sysMenus1 = selectSysChdMenuList(sysMenus);
|
||||
if (sysMenus1 != null){
|
||||
sysMenus.addAll(sysMenus1);
|
||||
}
|
||||
}else{
|
||||
return null;
|
||||
}
|
||||
return sysMenus;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询系统菜单列表
|
||||
*
|
||||
|
@ -97,32 +102,30 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|||
List<SysMenu> menuList = null;
|
||||
// 管理员显示所有菜单信息
|
||||
if (SysUser.isAdmin(userId)) {
|
||||
//获取符合查询的菜单信息
|
||||
menuList = menuMapper.selectMenuList(menu);
|
||||
|
||||
List<SysMenu> sysMenus = selectSysMenuList(menuList);
|
||||
|
||||
//查询菜单信息的所有父级菜单
|
||||
List<SysMenu> sysMenus1 = selectSysMenuList(menuList);
|
||||
if (sysMenus1!=null && sysMenus1.size()!=0){
|
||||
menuList.addAll(sysMenus1);
|
||||
}
|
||||
//查询菜单信息的所有子级菜单
|
||||
List<SysMenu> sysMenus = selectSysChdMenuList(menuMapper.selectMenuList(menu));
|
||||
if (sysMenus!=null && sysMenus.size()!=0){
|
||||
menuList.addAll(sysMenus);
|
||||
}
|
||||
|
||||
List<SysMenu> sysMenus1 = selectSysChdMenuList(menuMapper.selectMenuList(menu));
|
||||
if (sysMenus1 != null && sysMenus1.size() !=0) {
|
||||
menuList.addAll(sysMenus1);
|
||||
}
|
||||
} else {
|
||||
menu.getParams().put("userId", userId);
|
||||
menuList = menuMapper.selectMenuListByUserId(menu);
|
||||
}
|
||||
//菜单信息集合去重
|
||||
menuList = menuList.stream()
|
||||
.distinct()
|
||||
.toList();
|
||||
return menuList;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 根据用户ID查询权限
|
||||
*
|
||||
|
|
|
@ -1,13 +1,24 @@
|
|||
package com.muyu.system.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.security.utils.SecurityUtils;
|
||||
import com.muyu.system.domain.AsUserDept;
|
||||
import com.muyu.system.domain.SysNotice;
|
||||
import com.muyu.system.domain.req.SysNoticeRequest;
|
||||
import com.muyu.system.domain.resp.SysNoticeResponse;
|
||||
import com.muyu.system.mapper.AsUserDeptMapper;
|
||||
import com.muyu.system.mapper.SysNoticeMapper;
|
||||
import com.muyu.system.mapper.SysUserMapper;
|
||||
import com.muyu.system.service.SysNoticeService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 公告 服务层实现
|
||||
|
@ -19,6 +30,12 @@ public class SysNoticeServiceImpl extends ServiceImpl<SysNoticeMapper, SysNotice
|
|||
@Autowired
|
||||
private SysNoticeMapper noticeMapper;
|
||||
|
||||
@Autowired
|
||||
private SysUserMapper sysUserMapper;
|
||||
|
||||
@Autowired
|
||||
private AsUserDeptMapper asUserDeptMapper;
|
||||
|
||||
/**
|
||||
* 查询公告信息
|
||||
*
|
||||
|
@ -43,6 +60,36 @@ public class SysNoticeServiceImpl extends ServiceImpl<SysNoticeMapper, SysNotice
|
|||
return noticeMapper.selectNoticeList(notice);
|
||||
}
|
||||
|
||||
|
||||
public List<AsUserDept> handleList(List<Long> personnelList,List<List<Long>> sectionList,Long noticeId){
|
||||
List<Long> lons = new ArrayList<>();
|
||||
if (sectionList!=null && sectionList.size()!=0){
|
||||
sectionList.stream()
|
||||
.map(section -> {
|
||||
for (Long aLong : section) {
|
||||
lons.add(aLong);
|
||||
}
|
||||
return null;
|
||||
}).collect(Collectors.toList());
|
||||
List<Long> sectionIds = lons.stream().distinct().toList();
|
||||
List<Long> userIds=sysUserMapper.selectDtptUser(sectionIds);
|
||||
if (userIds!=null){
|
||||
personnelList.addAll(userIds);
|
||||
}
|
||||
}
|
||||
personnelList=personnelList.stream().distinct().toList();
|
||||
System.out.println(personnelList);
|
||||
List<AsUserDept> asUserDepts = personnelList.stream()
|
||||
.map(personnel -> {
|
||||
AsUserDept asUserDept = new AsUserDept();
|
||||
asUserDept.setUserId(personnel);
|
||||
asUserDept.setNoticeId(noticeId);
|
||||
asUserDept.setCreateBy(SecurityUtils.getUsername());
|
||||
asUserDept.setCreateTime(new Date());
|
||||
return asUserDept;
|
||||
}).toList();
|
||||
return asUserDepts;
|
||||
}
|
||||
/**
|
||||
* 新增公告
|
||||
*
|
||||
|
@ -51,8 +98,31 @@ public class SysNoticeServiceImpl extends ServiceImpl<SysNoticeMapper, SysNotice
|
|||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public int insertNotice (SysNotice notice) {
|
||||
return noticeMapper.insertNotice(notice);
|
||||
int i = noticeMapper.insertNotice(notice);
|
||||
|
||||
if (notice.getNoticeType().equals("1")){
|
||||
Long noticeId = notice.getNoticeId();
|
||||
List<Long> personnelList = notice.getPersonnelList();
|
||||
List<List<Long>> sectionList = notice.getSectionList();
|
||||
List<AsUserDept> asUserDepts = handleList(personnelList, sectionList, noticeId);
|
||||
asUserDeptMapper.insertBachAsUserDept(asUserDepts);
|
||||
}else{
|
||||
List<Long> userIds=noticeMapper.selectUser();
|
||||
List<AsUserDept> asUserDepts = userIds.stream()
|
||||
.map(id -> {
|
||||
AsUserDept asUserDept = new AsUserDept();
|
||||
asUserDept.setNoticeId(notice.getNoticeId());
|
||||
asUserDept.setCreateTime(new Date());
|
||||
asUserDept.setUserId(id);
|
||||
asUserDept.setCreateBy(SecurityUtils.getUsername());
|
||||
return asUserDept;
|
||||
}).toList();
|
||||
asUserDeptMapper.insertBachAsUserDept(asUserDepts);
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -90,4 +160,11 @@ public class SysNoticeServiceImpl extends ServiceImpl<SysNoticeMapper, SysNotice
|
|||
public int deleteNoticeByIds (Long[] noticeIds) {
|
||||
return noticeMapper.deleteNoticeByIds(noticeIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<List<SysNoticeResponse>> getNoticeList(SysNoticeRequest sysNoticeRequest) {
|
||||
sysNoticeRequest.setUserId(SecurityUtils.getUserId());
|
||||
List<SysNoticeResponse> noticeList = noticeMapper.getNoticeList(sysNoticeRequest);
|
||||
return Result.success(noticeList);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,104 @@
|
|||
<?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.muyu.system.mapper.AsUserDeptMapper">
|
||||
|
||||
<resultMap type="com.muyu.system.domain.AsUserDept" id="AsUserDeptResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="userId" column="user_id" />
|
||||
<result property="noticeId" column="notice_id" />
|
||||
<result property="isRead" column="is_read" />
|
||||
<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" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectAsUserDeptVo">
|
||||
select id, user_id, notice_id, is_read, create_by, create_time, update_by, update_time, remark from as_user_dept
|
||||
</sql>
|
||||
|
||||
<select id="selectAsUserDeptList" parameterType="com.muyu.system.domain.AsUserDept" resultMap="AsUserDeptResult">
|
||||
<include refid="selectAsUserDeptVo"/>
|
||||
<where>
|
||||
<if test="userId != null "> and user_id = #{userId}</if>
|
||||
<if test="noticeId != null "> and notice_id = #{noticeId}</if>
|
||||
<if test="isRead != null and isRead != ''"> and is_read = #{isRead}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectAsUserDeptById" parameterType="Long" resultMap="AsUserDeptResult">
|
||||
<include refid="selectAsUserDeptVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
<select id="selectAsUserDeptNum" resultType="java.lang.Long">
|
||||
select count(*) from as_user_dept where notice_id=#{noticeId}
|
||||
</select>
|
||||
<select id="selectAsUserDeptReadNum" resultType="java.lang.Long">
|
||||
select count(*) from as_user_dept where notice_id=#{noticeId} and is_read = '0'
|
||||
</select>
|
||||
|
||||
<insert id="insertAsUserDept" parameterType="com.muyu.system.domain.AsUserDept" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into as_user_dept
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="userId != null">user_id,</if>
|
||||
<if test="noticeId != null">notice_id,</if>
|
||||
<if test="isRead != null">is_read,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="remark != null">remark,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="userId != null">#{userId},</if>
|
||||
<if test="noticeId != null">#{noticeId},</if>
|
||||
<if test="isRead != null">#{isRead},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="remark != null">#{remark},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<insert id="insertBachAsUserDept">
|
||||
INSERT INTO `as_user_dept` (`user_id`, `notice_id`, `create_by`, `create_time`)
|
||||
VALUES
|
||||
<foreach collection="asUserDepts" separator="," item="asUserDept">
|
||||
(#{asUserDept.userId}, #{asUserDept.noticeId}, #{asUserDept.createBy}, #{asUserDept.createTime})
|
||||
</foreach>
|
||||
|
||||
|
||||
</insert>
|
||||
|
||||
<update id="updateAsUserDept" parameterType="com.muyu.system.domain.AsUserDept">
|
||||
update as_user_dept
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="userId != null">user_id = #{userId},</if>
|
||||
<if test="noticeId != null">notice_id = #{noticeId},</if>
|
||||
<if test="isRead != null">is_read = #{isRead},</if>
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
<update id="updateAsUserDeptRead">
|
||||
update as_user_dept set is_read = 0 where id=#{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteAsUserDeptById" parameterType="Long">
|
||||
delete from as_user_dept where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteAsUserDeptByIds" parameterType="String">
|
||||
delete from as_user_dept where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
|
@ -50,8 +50,23 @@
|
|||
</if>
|
||||
</where>
|
||||
</select>
|
||||
<select id="getNoticeList" resultType="com.muyu.system.domain.resp.SysNoticeResponse">
|
||||
select id,a.notice_id,is_read,a.create_by,a.create_time,notice_title,notice_content,notice_type
|
||||
from as_user_dept a join sys_notice n on a.notice_id=n.notice_id
|
||||
|
||||
<insert id="insertNotice" parameterType="com.muyu.system.domain.SysNotice">
|
||||
where a.user_id=#{userId}
|
||||
<if test="isRead !=null and isRead!=''">
|
||||
and is_read = #{isRead}
|
||||
</if>
|
||||
<if test="noticeType !=null and noticeType!=''">
|
||||
and n.notice_type = #{noticeType}
|
||||
</if>
|
||||
</select>
|
||||
<select id="selectUser" resultType="java.lang.Long">
|
||||
select user_id from sys_user
|
||||
</select>
|
||||
|
||||
<insert id="insertNotice" parameterType="com.muyu.system.domain.SysNotice" useGeneratedKeys="true" keyProperty="noticeId">
|
||||
insert into sys_notice (
|
||||
<if test="noticeTitle != null and noticeTitle != '' ">notice_title,</if>
|
||||
<if test="noticeType != null and noticeType != '' ">notice_type,</if>
|
||||
|
|
|
@ -183,6 +183,13 @@
|
|||
and del_flag = '0'
|
||||
limit 1
|
||||
</select>
|
||||
<select id="selectDtptUser" resultType="java.lang.Long">
|
||||
select user_id from sys_user where dept_id in (
|
||||
<foreach collection="sectionIds" separator="," item="id">
|
||||
#{id}
|
||||
</foreach>
|
||||
)
|
||||
</select>
|
||||
|
||||
<insert id="insertUser" parameterType="com.muyu.common.system.domain.SysUser" useGeneratedKeys="true" keyProperty="userId">
|
||||
insert into sys_user(
|
||||
|
|
Loading…
Reference in New Issue