From 8e33f56223feb9ad4357b3c70985e8aaa3153219 Mon Sep 17 00:00:00 2001 From: panqihua Date: Thu, 12 Jan 2023 07:52:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=89=B9=E9=87=8F=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E7=8A=B6=E6=80=81=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/controller/system/SysUserController.java | 12 ++++++++++++ .../java/com/ruoyi/system/mapper/SysUserMapper.java | 3 +++ .../com/ruoyi/system/service/ISysUserService.java | 6 ++++++ .../system/service/impl/SysUserServiceImpl.java | 10 ++++++++++ .../main/resources/mapper/system/SysUserMapper.xml | 7 +++++++ 5 files changed, 38 insertions(+) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java index 9dad2b4..2075461 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java @@ -254,4 +254,16 @@ public class SysUserController extends BaseController public AjaxResult select(@PathVariable String phonenumber){ return success(userService.queryUserByPhone(phonenumber)); } + + @PreAuthorize("@ss.hasPermi('system:user:edit')") + @Log(title = "用户管理", businessType = BusinessType.UPDATE) + @PutMapping("/updateStatus") + public AjaxResult updateStatus(Long[] userIds,String status) + { + if (ArrayUtils.contains(userIds, getUserId())) + { + return error("当前用户不能删除"); + } + return toAjax(userService.updateStatusByIds(userIds,status)); + } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java index 5f56bf2..2635144 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java @@ -5,6 +5,7 @@ import com.ruoyi.common.core.domain.entity.SysUser; import org.apache.ibatis.annotations.Param; import java.util.List; +import java.util.Map; /** * 用户表 数据层 @@ -126,4 +127,6 @@ public interface SysUserMapper extends BaseMapper * @return 结果 */ public SysUser checkEmailUnique(String email); + + public int updateStatusByIds(Map params); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java index fbff955..bc9971a 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java @@ -212,4 +212,10 @@ public interface ISysUserService */ public List queryUserByPhone(String phonenumber); + /** + * + * @param userIds 需要更新状态的用户id + * @return 结果 + */ + public int updateStatusByIds(Long[] userIds,String status); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java index 3560e16..52c9980 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java @@ -25,7 +25,9 @@ import org.springframework.util.CollectionUtils; import javax.validation.Validator; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.stream.Collectors; /** @@ -545,4 +547,12 @@ public class SysUserServiceImpl implements ISysUserService wrapper.select(SysUser::getUserId,SysUser::getPhonenumber).eq(SysUser::getDelFlag,"0").like(SysUser::getPhonenumber,phonenumber); return userMapper.selectList(wrapper); } + + @Override + public int updateStatusByIds(Long[] userIds,String status) { + Map params=new HashMap<>(); + params.put("userIds",userIds); + params.put("status",status); + return userMapper.updateStatusByIds(params); + } } diff --git a/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml index 4fbd200..971e758 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml @@ -212,6 +212,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" update sys_user set status = #{status} where user_id = #{userId} + + update sys_user set status = #{status} where user_id in + + #{userId} + + + update sys_user set avatar = #{avatar} where user_name = #{userName}