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}