报表(未完成)

This commit is contained in:
磷叶 2024-10-22 18:06:15 +08:00
parent dd3cdb75d0
commit d921f2c6e7
8 changed files with 141 additions and 75 deletions

View File

@ -0,0 +1,20 @@
package com.ruoyi.system.domain.dto;
import com.ruoyi.common.core.domain.entity.SysUser;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.List;
/**
* @author wjh
* 2024/10/22
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class SysUserQuery extends SysUser {
@ApiModelProperty("用户ID列表")
private List<Long> userIds;
}

View File

@ -0,0 +1,14 @@
package com.ruoyi.system.domain.vo;
import com.ruoyi.common.core.domain.entity.SysUser;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* @author wjh
* 2024/10/22
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class SysUserVO extends SysUser {
}

View File

@ -1,6 +1,9 @@
package com.ruoyi.system.mapper;
import java.util.List;
import com.ruoyi.system.domain.dto.SysUserQuery;
import com.ruoyi.system.domain.vo.SysUserVO;
import org.apache.ibatis.annotations.Param;
import com.ruoyi.common.core.domain.entity.SysUser;
@ -17,7 +20,7 @@ public interface SysUserMapper
* @param sysUser 用户信息
* @return 用户信息集合信息
*/
public List<SysUser> selectUserList(SysUser sysUser);
public List<SysUserVO> selectUserList(SysUserQuery sysUser);
/**
* 根据条件分页查询已配用户角色列表

View File

@ -2,6 +2,8 @@ package com.ruoyi.system.service;
import java.util.List;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.system.domain.dto.SysUserQuery;
import com.ruoyi.system.domain.vo.SysUserVO;
/**
* 用户 业务层
@ -16,7 +18,7 @@ public interface ISysUserService
* @param user 用户信息
* @return 用户信息集合信息
*/
public List<SysUser> selectUserList(SysUser user);
public List<SysUserVO> selectUserList(SysUserQuery user);
/**
* 根据条件分页查询已分配用户角色列表

View File

@ -4,6 +4,9 @@ import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import javax.validation.Validator;
import com.ruoyi.system.domain.dto.SysUserQuery;
import com.ruoyi.system.domain.vo.SysUserVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -73,7 +76,7 @@ public class SysUserServiceImpl implements ISysUserService
*/
@Override
@DataScope(deptAlias = "d", userAlias = "u")
public List<SysUser> selectUserList(SysUser user)
public List<SysUserVO> selectUserList(SysUserQuery user)
{
return userMapper.selectUserList(user);
}
@ -240,9 +243,9 @@ public class SysUserServiceImpl implements ISysUserService
{
if (!SysUser.isAdmin(SecurityUtils.getUserId()))
{
SysUser user = new SysUser();
SysUserQuery user = new SysUserQuery();
user.setUserId(userId);
List<SysUser> users = SpringUtils.getAopProxy(this).selectUserList(user);
List<SysUserVO> users = SpringUtils.getAopProxy(this).selectUserList(user);
if (StringUtils.isEmpty(users))
{
throw new ServiceException("没有权限访问用户数据!");

View File

@ -4,7 +4,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.system.mapper.SysUserMapper">
<resultMap type="SysUser" id="SysUserResult" autoMapping="true">
<resultMap type="SysUserVO" id="SysUserResult" autoMapping="true">
<association property="dept" javaType="SysDept" resultMap="deptResult" />
<collection property="roles" javaType="java.util.List" resultMap="RoleResult" />
</resultMap>
@ -69,7 +69,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
left join sys_role r on r.role_id = ur.role_id
</sql>
<select id="selectUserList" parameterType="SysUser" resultMap="SysUserResult">
<select id="selectUserList" parameterType="SysUserQuery" resultMap="SysUserResult">
select
u.user_id,
u.dept_id,
@ -118,7 +118,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="deptId != null and deptId != 0">
AND (u.dept_id = #{deptId} OR u.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE find_in_set(#{deptId}, ancestors) ))
</if>
<if test="userIds != null and userIds.size() > 0">
AND u.user_id IN
<foreach collection="userIds" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<!-- 数据范围过滤 -->
${@com.ruoyi.framework.util.DataScopeUtil@dataScope("d", "u", needScope)}
${params.dataScope}
</select>

View File

@ -3,6 +3,9 @@ package com.ruoyi.web.system;
import java.util.List;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletResponse;
import com.ruoyi.system.domain.dto.SysUserQuery;
import com.ruoyi.system.domain.vo.SysUserVO;
import org.apache.commons.lang3.ArrayUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
@ -58,20 +61,34 @@ public class SysUserController extends BaseController
*/
@PreAuthorize("@ss.hasPermi('system:user:list')")
@GetMapping("/list")
public TableDataInfo list(SysUser user)
public TableDataInfo list(SysUserQuery user)
{
startPage();
List<SysUser> list = userService.selectUserList(user);
List<SysUserVO> list = userService.selectUserList(user);
return getDataTable(list);
}
/**
* 获取用户列表ByIds
*/
@PreAuthorize("@ss.hasPermi('system:user:list')")
@PostMapping("/listByIds")
public AjaxResult list(@RequestBody List<Long> userIds)
{
SysUserQuery query = new SysUserQuery();
query.setUserIds(userIds);
query.setNeedScope(true);
List<SysUserVO> list = userService.selectUserList(query);
return success(list);
}
@Log(title = "用户管理", businessType = BusinessType.EXPORT)
@PreAuthorize("@ss.hasPermi('system:user:export')")
@PostMapping("/export")
public void export(HttpServletResponse response, SysUser user)
public void export(HttpServletResponse response, SysUserQuery user)
{
List<SysUser> list = userService.selectUserList(user);
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
List<SysUserVO> list = userService.selectUserList(user);
ExcelUtil<SysUserVO> util = new ExcelUtil<SysUserVO>(SysUserVO.class);
util.exportExcel(response, list, "用户数据");
}

View File

@ -95,7 +95,7 @@ token:
# 令牌密钥
secret: abcdefghijklmnopqrstuvwxyz
# 令牌有效期默认30分钟
expireTime: 30
expireTime: 1440
# MyBatis配置
mybatis: