Commit b712f3b6 authored by fangxinjiang's avatar fangxinjiang

Merge remote-tracking branch 'origin/MVP1.5.8' into MVP1.5.8

parents c1f5b2df b9aeed9c
package com.yifu.cloud.plus.v1.yifu.permission.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.ExcelAttribute;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* 新权限-用户权限表
*
* @author hyc
* @date 2023-08-29 14:49:40
*/
@Data
public class SysUserPermissionExportVo implements Serializable {
/**
* 员工姓名
*/
@Length(max = 20, message = "员工姓名 不能超过20 个字符")
@ExcelAttribute(name = "员工姓名", maxLength = 20)
@Schema(description = "员工姓名")
@ExcelProperty("员工姓名")
private String empName;
/**
* 登录账号
*/
@NotBlank(message = "登录账号 不能为空")
@Length(max = 10, message = "登录账号 不能超过10 个字符")
@ExcelAttribute(name = "登录账号", isNotEmpty = true, errorInfo = "登录账号 不能为空", maxLength = 10)
@Schema(description = "登录账号")
@ExcelProperty("登录账号")
private String empLoginName;
/**
* 所属部门
*/
@Length(max = 20, message = "所属部门 不能超过20 个字符")
@ExcelAttribute(name = "所属部门", maxLength = 20)
@Schema(description = "所属部门")
@ExcelProperty("所属部门")
private String empDept;
/**
* 权限类型
*/
@Length(max = 8, message = "权限类型 不能超过8 个字符")
@ExcelAttribute(name = "权限类型", maxLength = 8)
@Schema(description = "权限类型")
@ExcelProperty("权限类型")
private String permissionType;
/**
* 名称
*/
@Length(max = 20, message = "名称 不能超过20 个字符")
@ExcelAttribute(name = "名称", maxLength = 20)
@Schema(description = "名称")
@ExcelProperty("名称")
private String name;
/**
* 编码
*/
@Length(max = 30, message = "编码 不能超过30 个字符")
@ExcelAttribute(name = "编码", maxLength = 30)
@Schema(description = "编码")
@ExcelProperty("编码")
private String code;
/**
* 是否包含(0 是 1否)
*/
@Length(max = 1, message = "是否含下级部门 不能超过1 个字符")
@ExcelAttribute(name = "是否含下级部门", maxLength = 1)
@Schema(description = "是否含下级部门")
@ExcelProperty("是否含下级部门")
private String isContains;
/**
* 授权状态(0启用、1禁用)
*/
@Length(max = 1, message = "授权状态 不能超过1 个字符")
@ExcelAttribute(name = "授权状态", maxLength = 1)
@Schema(description = "授权状态")
@ExcelProperty("授权状态")
private String permissionStatus;
}
......@@ -41,7 +41,7 @@ public class SysUserPermissionVo extends RowIndex implements Serializable {
* 用户id
*/
@Schema(description = "用户id")
@ExcelAttribute(name = "用户id",isExport = false)
@ExcelAttribute(name = "用户id")
private String userId;
/**
......@@ -71,8 +71,8 @@ public class SysUserPermissionVo extends RowIndex implements Serializable {
/**
* 编码
*/
@Length(max = 10, message = "编码 不能超过10 个字符")
@ExcelAttribute(name = "编码", maxLength = 10)
@Length(max = 30, message = "编码 不能超过30 个字符")
@ExcelAttribute(name = "编码", maxLength = 30)
@Schema(description = "编码")
@ExcelProperty("编码")
private String code;
......
......@@ -158,12 +158,12 @@ public class SysUserInfoController {
* 简单分页查询
* hyc 2023-9-11 15:25:50
* @param page 分页对象
* @param code 新权限-账号管理表
* @param name 新权限-账号管理表
* @return
*/
@Operation(description = "根据编码或者登录名简单分页查询")
@GetMapping("/getUserByCodeOrLoginName")
public R<IPage<SysUserInfo>> getUserByCodeOrLoginName(Page<SysUserInfo> page, String code) {
return new R<>(sysUserInfoService.getUserByCodeOrLoginName(page, code));
public R<IPage<SysUserInfo>> getUserByCodeOrLoginName(Page<SysUserInfo> page, String name) {
return new R<>(sysUserInfoService.getUserByCodeOrLoginName(page, name));
}
}
......@@ -6,8 +6,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yifu.cloud.plus.v1.yifu.permission.entity.SysUserPermission;
import com.yifu.cloud.plus.v1.yifu.permission.vo.SysDictVo;
import com.yifu.cloud.plus.v1.yifu.permission.vo.SysUserDeptVo;
import com.yifu.cloud.plus.v1.yifu.permission.vo.SysUserPermissionExportVo;
import com.yifu.cloud.plus.v1.yifu.permission.vo.SysUserPermissionSearchVo;
import com.yifu.cloud.plus.v1.yifu.permission.vo.SysUserPermissionVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
......@@ -43,7 +43,7 @@ public interface SysUserPermissionMapper extends BaseMapper<SysUserPermission> {
* @param sysUserPermission 新权限-用户权限表
* @return
*/
List<SysUserPermissionVo> userSelectList(@Param("sysUserPermission") SysUserPermissionSearchVo sysUserPermission);
List<SysUserPermissionExportVo> userSelectList(@Param("sysUserPermission") SysUserPermissionSearchVo sysUserPermission);
/**
* 根据名称或者编码查询数据
......
......@@ -21,10 +21,7 @@ import com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser;
import com.yifu.cloud.plus.v1.yifu.common.security.util.SecurityUtils;
import com.yifu.cloud.plus.v1.yifu.permission.entity.SysUserInfo;
import com.yifu.cloud.plus.v1.yifu.permission.entity.SysUserPermission;
import com.yifu.cloud.plus.v1.yifu.permission.vo.SysDictVo;
import com.yifu.cloud.plus.v1.yifu.permission.vo.SysUserDeptVo;
import com.yifu.cloud.plus.v1.yifu.permission.vo.SysUserPermissionSearchVo;
import com.yifu.cloud.plus.v1.yifu.permission.vo.SysUserPermissionVo;
import com.yifu.cloud.plus.v1.yifu.permission.vo.*;
import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -105,14 +102,14 @@ public class SysUserPermissionServiceImpl extends ServiceImpl<SysUserPermissionM
public void listExport(HttpServletResponse response, SysUserPermissionSearchVo searchVo) {
String fileName = "数据权限表批量导出" + DateUtil.getThisTime() + ".xlsx";
//获取要导出的列表
List<SysUserPermissionVo> list = new ArrayList<>();
List<SysUserPermissionExportVo> list = new ArrayList<>();
long count = baseMapper.userSelectCount(searchVo);
try (ServletOutputStream out = response.getOutputStream()) {
response.setContentType(CommonConstants.MULTIPART_FORM_DATA);
response.setCharacterEncoding("utf-8");
response.setHeader(CommonConstants.CONTENT_DISPOSITION, CommonConstants.ATTACHMENT_FILENAME + URLEncoder.encode(fileName, CommonConstants.UTF8));
// 这里 需要指定写用哪个class去写,然后写到第一个sheet,然后文件流会自动关闭
ExcelWriter excelWriter = EasyExcel.write(out, SysUserPermissionVo.class).build();
ExcelWriter excelWriter = EasyExcel.write(out, SysUserPermissionExportVo.class).build();
int index = 0;
if (count > CommonConstants.ZERO_INT) {
for (int i = 0; i <= count; i += CommonConstants.EXCEL_EXPORT_LIMIT) {
......@@ -223,6 +220,7 @@ public class SysUserPermissionServiceImpl extends ServiceImpl<SysUserPermissionM
data.setRowIndex(rowIndex + 1);
ErrorMessage errorMessage = util1.checkEntity(data, data.getRowIndex());
if (Common.isNotNull(errorMessage)) {
errorMessage.setData(data);
errorMessageList.add(errorMessage);
} else {
cachedDataList.add(data);
......@@ -266,7 +264,6 @@ public class SysUserPermissionServiceImpl extends ServiceImpl<SysUserPermissionM
// 执行数据插入操作 组装
for (int i = 0; i < excelVOList.size(); i++) {
SysUserPermissionVo excel = excelVOList.get(i);
//登录名校验
userInfo = userInfoList.stream().filter(e -> excel.getEmpLoginName().equals(e.getFdLoginName())).collect(Collectors.toList());
if (userInfo.isEmpty()) {
......@@ -279,6 +276,8 @@ public class SysUserPermissionServiceImpl extends ServiceImpl<SysUserPermissionM
excel.setEmpDept(sysUserInfo.getFdDeptName());
excel.setEmpName(sysUserInfo.getFdName());
excel.setUserId(sysUserInfo.getFdId());
SysUserPermission insert = new SysUserPermission();
BeanUtil.copyProperties(excel, insert);
//判断表格权限类型是否正确
if (typeMap.isEmpty()) {
errorMessageList.add(new ErrorMessage(excel.getRowIndex(), "获取权限类型字典值异常", excel));
......@@ -289,14 +288,14 @@ public class SysUserPermissionServiceImpl extends ServiceImpl<SysUserPermissionM
errorMessageList.add(new ErrorMessage(excel.getRowIndex(), "权限类型填写错误,请核实", excel));
continue;
} else {
excel.setPermissionType(typeMap.get(excel.getPermissionType()));
insert.setPermissionType(typeMap.get(excel.getPermissionType()));
}
//登录账号+维度+唯一标识唯一
StringBuilder flag = new StringBuilder();
flag.append(excel.getEmpLoginName());
flag.append("_");
flag.append(excel.getPermissionType());
flag.append(insert.getPermissionType());
flag.append("_");
flag.append(excel.getCode());
if (null != uniqueMap.get(flag.toString())) {
......@@ -308,11 +307,11 @@ public class SysUserPermissionServiceImpl extends ServiceImpl<SysUserPermissionM
//BU和条线的时候用名称判断,其他用编码判断
//判断此登录名是否已经存在此权限维度
if (CommonConstants.SIX_STRING.equals(excel.getPermissionType())
|| CommonConstants.SEVEN_STRING.equals(excel.getPermissionType())) {
if (CommonConstants.SIX_STRING.equals(insert.getPermissionType())
|| CommonConstants.SEVEN_STRING.equals(insert.getPermissionType())) {
//判断对应维度的名称是否存在
Integer count;
if (CommonConstants.SIX_STRING.equals(excel.getPermissionType())) {
if (CommonConstants.SIX_STRING.equals(insert.getPermissionType())) {
count = baseMapper.selectDictByName(excel.getName(), "bu");
} else {
count = baseMapper.selectDictByName(excel.getName(), "line");
......@@ -323,7 +322,7 @@ public class SysUserPermissionServiceImpl extends ServiceImpl<SysUserPermissionM
}
permission = this.getOne(Wrappers.<SysUserPermission>query().lambda()
.eq(SysUserPermission::getEmpLoginName, excel.getEmpLoginName())
.eq(SysUserPermission::getPermissionType, excel.getPermissionType())
.eq(SysUserPermission::getPermissionType, insert.getPermissionType())
.eq(SysUserPermission::getName, excel.getName()).last(CommonConstants.LAST_ONE_SQL));
if (Common.isNotNull(permission)) {
errorMessageList.add(new ErrorMessage(excel.getRowIndex(), "系统中已经存在该用户对应的名称权限维度", excel));
......@@ -331,14 +330,14 @@ public class SysUserPermissionServiceImpl extends ServiceImpl<SysUserPermissionM
}
} else {
//判断对应维度的编码是否存在
Integer count = this.checkExit(excel.getPermissionType(), excel.getCode());
Integer count = this.checkExit(insert.getPermissionType(), excel.getCode());
if (count < 1) {
errorMessageList.add(new ErrorMessage(excel.getRowIndex(), "不存在对应维度的编码信息", excel));
continue;
}
permission = this.getOne(Wrappers.<SysUserPermission>query().lambda()
.eq(SysUserPermission::getEmpLoginName, excel.getEmpLoginName())
.eq(SysUserPermission::getPermissionType, excel.getPermissionType())
.eq(SysUserPermission::getPermissionType, insert.getPermissionType())
.eq(SysUserPermission::getCode, excel.getCode()).last(CommonConstants.LAST_ONE_SQL));
if (Common.isNotNull(permission)) {
errorMessageList.add(new ErrorMessage(excel.getRowIndex(), "系统中已经存在该用户对应的编码的权限维度", excel));
......@@ -352,7 +351,7 @@ public class SysUserPermissionServiceImpl extends ServiceImpl<SysUserPermissionM
permission = this.getOne(Wrappers.<SysUserPermission>query().lambda()
.eq(SysUserPermission::getPermissionStatus, CommonConstants.ZERO_STRING)
.eq(SysUserPermission::getEmpLoginName, user.getUsername())
.eq(SysUserPermission::getPermissionType, excel.getPermissionType())
.eq(SysUserPermission::getPermissionType, insert.getPermissionType())
.eq(SysUserPermission::getCode, excel.getCode()).last(CommonConstants.LAST_ONE_SQL));
if (Common.isEmpty(permission)) {
errorMessageList.add(new ErrorMessage(excel.getRowIndex(), "只有自己有权限的维度才可导入", excel));
......@@ -360,7 +359,7 @@ public class SysUserPermissionServiceImpl extends ServiceImpl<SysUserPermissionM
}
}
// 插入数据
insertExcel(excel);
insertExcel(insert);
}
} catch (Exception e) {
log.error("用户权限表导入异常:" + e);
......@@ -370,9 +369,7 @@ public class SysUserPermissionServiceImpl extends ServiceImpl<SysUserPermissionM
/**
* 插入excel bad record
*/
private void insertExcel(SysUserPermissionVo excel) {
SysUserPermission insert = new SysUserPermission();
BeanUtil.copyProperties(excel, insert);
private void insertExcel(SysUserPermission insert ) {
//转化是否含下级
if (Common.isNotNull(insert.getIsContains())) {
if (CommonConstants.IS_TRUE.equals(insert.getIsContains())) {
......
......@@ -51,7 +51,7 @@
<sql id="sysMenu_where">
<if test="sysMenu != null">
<if test="sysMenu.menuName != null and sysMenu.menuName.trim() != ''">
AND a.MENU_NAME = #{sysMenu.menuName}
AND a.MENU_NAME like concat('%',#{sysMenu.menuName},'%')
</if>
<if test="sysMenu.menuNameParent != null and sysMenu.menuNameParent.trim() != ''">
AND a.MENU_NAME_PARENT = #{sysMenu.menuNameParent}
......
......@@ -201,7 +201,7 @@
a.fd_dept_name
FROM sys_user_info a
<where>
1=1
1=1 and a.status = 0
<if test="code != null and code != ''">
AND (a.fd_login_name like concat('%',#{code},'%') or a.fd_name like concat('%',#{code},'%'))
</if>
......
......@@ -21,7 +21,7 @@
<result property="updateTime" column="UPDATE_TIME"/>
</resultMap>
<resultMap id="sysUserPermissionExportMap" type="com.yifu.cloud.plus.v1.yifu.permission.vo.SysUserPermissionVo">
<resultMap id="sysUserPermissionExportMap" type="com.yifu.cloud.plus.v1.yifu.permission.vo.SysUserPermissionExportVo">
<result property="empName" column="EMP_NAME"/>
<result property="empLoginName" column="EMP_LOGIN_NAME"/>
<result property="empDept" column="EMP_DEPT"/>
......
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