增加批量更新状态接口

master
panqihua 2 years ago
parent 19cacf4c48
commit 8e33f56223
  1. 12
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java
  2. 3
      ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java
  3. 6
      ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java
  4. 10
      ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java
  5. 7
      ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml

@ -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));
}
}

@ -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<SysUser>
* @return 结果
*/
public SysUser checkEmailUnique(String email);
public int updateStatusByIds(Map<String,Object> params);
}

@ -212,4 +212,10 @@ public interface ISysUserService
*/
public List<SysUser> queryUserByPhone(String phonenumber);
/**
*
* @param userIds 需要更新状态的用户id
* @return 结果
*/
public int updateStatusByIds(Long[] userIds,String status);
}

@ -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<String,Object> params=new HashMap<>();
params.put("userIds",userIds);
params.put("status",status);
return userMapper.updateStatusByIds(params);
}
}

@ -212,6 +212,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
update sys_user set status = #{status} where user_id = #{userId}
</update>
<update id="updateStatusByIds" parameterType="Map">
update sys_user set status = #{status} where user_id in
<foreach collection="userIds" item="userId" open="(" separator="," close=")">
#{userId}
</foreach>
</update>
<update id="updateUserAvatar" parameterType="SysUser">
update sys_user set avatar = #{avatar} where user_name = #{userName}
</update>

Loading…
Cancel
Save