Commit 09e54f0b authored by wdy's avatar wdy

Merge branch 'wangdingyi' into 'dev'

删除用户判断

See merge request !304
parents 54d0c773 9dc3b557
...@@ -22,6 +22,10 @@ ...@@ -22,6 +22,10 @@
<groupId>com.ruoyi</groupId> <groupId>com.ruoyi</groupId>
<artifactId>ruoyi-common</artifactId> <artifactId>ruoyi-common</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
</dependencies> </dependencies>
......
package com.ruoyi.system.domain.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
import lombok.Data;
@Data
@Builder
@ApiModel("检验员VO")
public class UserCountVo {
@ApiModelProperty("检验员id")
private Long userId;
@ApiModelProperty("用户所进行任务数量")
private Long countNum;
@ApiModelProperty("用户名")
private String nikeName;
}
package com.ruoyi.system.mapper; package com.ruoyi.system.mapper;
import java.util.List; import java.util.List;
import com.ruoyi.system.domain.vo.UserCountVo;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.core.domain.entity.SysUser;
...@@ -138,4 +139,11 @@ public interface SysUserMapper ...@@ -138,4 +139,11 @@ public interface SysUserMapper
* @return * @return
*/ */
List<SysUser> selectUserListByRoleId(@Param("roleId") Long roleId); List<SysUser> selectUserListByRoleId(@Param("roleId") Long roleId);
/**
* 查询用户所含进行中任务数
* @param userIds
* @return
*/
List<UserCountVo> countTaskByUserId(@Param("userIds") Long[] userIds);
} }
...@@ -6,6 +6,7 @@ import java.util.stream.Collectors; ...@@ -6,6 +6,7 @@ import java.util.stream.Collectors;
import javax.validation.Validator; import javax.validation.Validator;
import com.ruoyi.common.core.domain.entity.SysDept; import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.system.domain.vo.UserCountVo;
import com.ruoyi.system.mapper.*; import com.ruoyi.system.mapper.*;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -475,6 +476,17 @@ public class SysUserServiceImpl implements ISysUserService ...@@ -475,6 +476,17 @@ public class SysUserServiceImpl implements ISysUserService
checkUserAllowed(new SysUser(userId)); checkUserAllowed(new SysUser(userId));
checkUserDataScope(userId); checkUserDataScope(userId);
} }
List<UserCountVo> list = userMapper.countTaskByUserId(userIds);
StringBuilder msg = new StringBuilder();
for (UserCountVo countVo : list) {
if (countVo.getCountNum() > 0) {
msg.append(countVo.getNikeName()).append("、");
}
}
if (StringUtils.isNotEmpty(msg.toString())) {
msg = new StringBuilder(msg.substring(0, msg.length() - 1));
throw new ServiceException("用户:" + msg +"存在进行中的任务,不能删除");
}
// 删除用户与角色关联 // 删除用户与角色关联
userRoleMapper.deleteUserRole(userIds); userRoleMapper.deleteUserRole(userIds);
// 删除用户与岗位关联 // 删除用户与岗位关联
......
...@@ -229,5 +229,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -229,5 +229,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{userId} #{userId}
</foreach> </foreach>
</delete> </delete>
<select id="countTaskByUserId" resultType="com.ruoyi.system.domain.vo.UserCountVo">
select count(*) countNum, tr.user_id userId, s.nick_name nikeName
from t_task t
left join t_task_user_relation tr on tr.task_id = t.id
left join sys_user s on s.user_id = tr.user_id
where t.task_status in ('NEW','PENDING') and tr.user_id in
<foreach item="item" collection="userIds" open="(" separator="," close=")">
#{item}
</foreach>
group by tr.user_id
</select>
</mapper> </mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment