fix:消息增加全部已读接口。部门新增时自动生成编码,用户导入数据时使用部门编码

This commit is contained in:
zhangxuanming
2024-12-30 11:41:00 +08:00
parent afc92b8bf6
commit 4d645ef15a
15 changed files with 391 additions and 9 deletions

View File

@@ -115,4 +115,10 @@ public interface SysDeptMapper
* @return 结果
*/
public int deleteDeptById(Long deptId);
/**
* 查询所有部门数据
* @return
*/
List<SysDept> selectAllDeptList();
}

View File

@@ -58,4 +58,6 @@ public interface SysMessageMapper
* @return 结果
*/
public int deleteSysMessageByMessageIds(Long[] messageIds);
List<SysMessage> getUnRead();
}

View File

@@ -113,4 +113,10 @@ public interface ISysDeptService
* @return 结果
*/
public int deleteDeptById(Long deptId);
/**
* 查询所有部门数据
* @return
*/
List<SysDept> selectAllDeptList();
}

View File

@@ -1,6 +1,8 @@
package com.ktg.system.service;
import java.util.List;
import com.ktg.common.core.domain.AjaxResult;
import com.ktg.system.domain.SysMessage;
/**
@@ -58,4 +60,10 @@ public interface ISysMessageService
* @return 结果
*/
public int deleteSysMessageByMessageId(Long messageId);
/**
* 全部已读
* @return
*/
AjaxResult allRead();
}

View File

@@ -2,6 +2,7 @@ package com.ktg.system.service;
import java.util.List;
import com.ktg.common.core.domain.entity.SysUser;
import com.ktg.common.core.domain.vo.SysUserExcelVO;
/**
* 用户 业务层
@@ -209,7 +210,7 @@ public interface ISysUserService
* @param operName 操作用户
* @return 结果
*/
public String importUser(List<SysUser> userList, Boolean isUpdateSupport, String operName);
public String importUser(List<SysUserExcelVO> userList, Boolean isUpdateSupport, String operName);
/**
* 校验昵称是否存在

View File

@@ -284,6 +284,11 @@ public class SysDeptServiceImpl implements ISysDeptService
return deptMapper.deleteDeptById(deptId);
}
@Override
public List<SysDept> selectAllDeptList() {
return deptMapper.selectAllDeptList();
}
/**
* 递归列表
*/

View File

@@ -1,6 +1,8 @@
package com.ktg.system.service.impl;
import java.util.List;
import com.ktg.common.core.domain.AjaxResult;
import com.ktg.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -93,4 +95,19 @@ public class SysMessageServiceImpl implements ISysMessageService
{
return sysMessageMapper.deleteSysMessageByMessageId(messageId);
}
/**
* 全部已读
* @return
*/
@Override
public AjaxResult allRead() {
// 查询所有未读消息
List<SysMessage> messages = sysMessageMapper.getUnRead();
messages.forEach(item -> {
item.setStatus("READ");
sysMessageMapper.updateSysMessage(item);
});
return AjaxResult.success();
}
}

View File

@@ -2,12 +2,18 @@ package com.ktg.system.service.impl;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
import javax.validation.Validator;
import cn.hutool.core.util.ObjectUtil;
import com.ktg.common.core.domain.entity.SysDept;
import com.ktg.common.core.domain.vo.SysUserExcelVO;
import com.ktg.system.service.ISysDeptService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -63,6 +69,9 @@ public class SysUserServiceImpl implements ISysUserService
@Autowired
protected Validator validator;
@Autowired
private ISysDeptService deptService;
/**
* 根据条件分页查询用户列表
*
@@ -508,7 +517,7 @@ public class SysUserServiceImpl implements ISysUserService
* @return 结果
*/
@Override
public String importUser(List<SysUser> userList, Boolean isUpdateSupport, String operName)
public String importUser(List<SysUserExcelVO> userList, Boolean isUpdateSupport, String operName)
{
if (StringUtils.isNull(userList) || userList.size() == 0)
{
@@ -518,9 +527,17 @@ public class SysUserServiceImpl implements ISysUserService
int failureNum = 0;
StringBuilder successMsg = new StringBuilder();
StringBuilder failureMsg = new StringBuilder();
// 查询所有部门数据
List<SysDept> depts = deptService.selectAllDeptList();
Map<String, SysDept> collect = depts.stream().collect(Collectors.toMap(
SysDept::getDeptCode,
Function.identity()
));
String password = configService.selectConfigByKey("sys.user.initPassword");
for (SysUser user : userList)
for (SysUserExcelVO uservo : userList)
{
SysUser user = new SysUser();
BeanUtils.copyProperties(uservo, user);
try
{
if (ObjectUtil.isEmpty(user.getNickName())) {
@@ -533,6 +550,9 @@ public class SysUserServiceImpl implements ISysUserService
failureMsg.append("<br/>" + "昵称重复");
continue;
}
if (ObjectUtil.isNotEmpty(uservo.getDeptCode())) {
user.setDeptId(collect.get(uservo.getDeptCode()).getDeptId());
}
// 验证是否存在这个用户
SysUser u = userMapper.selectUserByUserName(user.getUserName());
if (StringUtils.isNull(u))

View File

@@ -8,6 +8,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<id property="deptId" column="dept_id" />
<result property="parentId" column="parent_id" />
<result property="ancestors" column="ancestors" />
<result property="deptCode" column="dept_code" />
<result property="deptName" column="dept_name" />
<result property="orderNum" column="order_num" />
<result property="leader" column="leader" />
@@ -23,7 +24,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectDeptVo">
select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time
select d.dept_id, d.parent_id, d.ancestors, d.dept_code, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time
from sys_dept d
</sql>
@@ -84,11 +85,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectDeptVo"/>
where dept_name=#{deptName} and parent_id = #{parentId} and del_flag = '0' limit 1
</select>
<select id="selectAllDeptList" resultType="com.ktg.common.core.domain.entity.SysDept" resultMap="SysDeptResult">
<include refid="selectDeptVo"/>
</select>
<insert id="insertDept" parameterType="SysDept">
<insert id="insertDept" parameterType="SysDept">
insert into sys_dept(
<if test="deptId != null and deptId != 0">dept_id,</if>
<if test="parentId != null and parentId != 0">parent_id,</if>
<if test="deptCode != null and deptCode != ''">dept_code,</if>
<if test="deptName != null and deptName != ''">dept_name,</if>
<if test="ancestors != null and ancestors != ''">ancestors,</if>
<if test="orderNum != null and orderNum != ''">order_num,</if>
@@ -101,7 +106,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
)values(
<if test="deptId != null and deptId != 0">#{deptId},</if>
<if test="parentId != null and parentId != 0">#{parentId},</if>
<if test="deptName != null and deptName != ''">#{deptName},</if>
<if test="deptCode != null and deptCode != ''">#{deptCode},</if>
<if test="deptCode != null and deptCode != ''">#{deptName},</if>
<if test="ancestors != null and ancestors != ''">#{ancestors},</if>
<if test="orderNum != null and orderNum != ''">#{orderNum},</if>
<if test="leader != null and leader != ''">#{leader},</if>

View File

@@ -60,7 +60,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectSysMessageVo"/>
where message_id = #{messageId}
</select>
<select id="getUnRead" resultType="com.ktg.system.domain.SysMessage" resultMap="SysMessageResult">
<include refid="selectSysMessageVo"/>
where status = 'UNREAD'
</select>
<insert id="insertSysMessage" parameterType="SysMessage" useGeneratedKeys="true" keyProperty="messageId">
insert into sys_message
<trim prefix="(" suffix=")" suffixOverrides=",">