Commit 98efd041 authored by huyuchen's avatar huyuchen

菜单权限修改

parent 17e5badc
...@@ -140,4 +140,9 @@ public class SysMenu extends BaseEntity { ...@@ -140,4 +140,9 @@ public class SysMenu extends BaseEntity {
@TableField(exist = false) @TableField(exist = false)
private List<String> columnIdList; private List<String> columnIdList;
/**
* 是否开关(0开、1关)
*/
@Schema(description = "是否开关(0开、1关)")
private String isOpen;
} }
...@@ -88,4 +88,9 @@ public class SysUserPermission extends BaseEntity { ...@@ -88,4 +88,9 @@ public class SysUserPermission extends BaseEntity {
@Schema(description = "删除状态(0是、1否)") @Schema(description = "删除状态(0是、1否)")
private String deleteFlag; private String deleteFlag;
/**
* 项目id
*/
@Schema(description = "项目id")
private String domainId;
} }
...@@ -53,4 +53,10 @@ public class SysUserDeptVo implements Serializable { ...@@ -53,4 +53,10 @@ public class SysUserDeptVo implements Serializable {
@Schema(description = "登录名") @Schema(description = "登录名")
private String loginName; private String loginName;
/**
* 项目id
*/
@Schema(description = "项目id")
private String domainId;
} }
\ No newline at end of file
...@@ -63,8 +63,8 @@ public class SysUserPermissionVo extends RowIndex implements Serializable { ...@@ -63,8 +63,8 @@ public class SysUserPermissionVo extends RowIndex implements Serializable {
/** /**
* 名称 * 名称
*/ */
@Length(max = 20, message = "名称 不能超过20 个字符") @Length(max = 200, message = "名称 不能超过200 个字符")
@ExcelAttribute(name = "名称", maxLength = 20) @ExcelAttribute(name = "名称", maxLength = 200)
@Schema(description = "名称") @Schema(description = "名称")
@ExcelProperty("名称") @ExcelProperty("名称")
private String name; private String name;
......
...@@ -32,6 +32,16 @@ public interface SysMenuMapper extends BaseMapper<SysMenu> { ...@@ -32,6 +32,16 @@ public interface SysMenuMapper extends BaseMapper<SysMenu> {
*/ */
long selectMenuId(@Param("modelId") String modelId); long selectMenuId(@Param("modelId") String modelId);
/**
* 判断是否存在此菜单视图
*
* @param modelId 表单id
* @Author: huyc
* @Date: 2023/8/30 14:20
* @return
*/
long selectViewId(@Param("viewId") String viewId,@Param("modelId") String modelId);
/** /**
* 判断是否存在此字段 * 判断是否存在此字段
* *
......
...@@ -77,6 +77,14 @@ public interface SysUserPermissionMapper extends BaseMapper<SysUserPermission> { ...@@ -77,6 +77,14 @@ public interface SysUserPermissionMapper extends BaseMapper<SysUserPermission> {
*/ */
IPage<SysUserDeptVo> selectSettleVO(Page<SysUserDeptVo> page, @Param("name") String name); IPage<SysUserDeptVo> selectSettleVO(Page<SysUserDeptVo> page, @Param("name") String name);
/**
* 根据名项目编码查询id
* 项目权限
* @param code 编码
* @return
*/
String selectSettleByCode(@Param("code") String code);
/** /**
* 根据名称或者编码查询数据 * 根据名称或者编码查询数据
* 商机权限 * 商机权限
......
...@@ -55,13 +55,23 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl ...@@ -55,13 +55,23 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
if (menuIdCount < 1) { if (menuIdCount < 1) {
return R.failed("表单ID填写错误,请确认"); return R.failed("表单ID填写错误,请确认");
} }
//唯一性校验--表单ID唯一 //判断view id是否填写正确并且要属于modeleID
long viewIdCount = baseMapper.selectViewId(menu.getViewId(),menu.getModelId());
if (viewIdCount < 1) {
return R.failed("视图ID不存在或者不属于填写的表单id,请确认");
}
//唯一性校验--视图ID唯一
long modelCount = baseMapper.selectCount(Wrappers.<SysMenu>query().lambda() long modelCount = baseMapper.selectCount(Wrappers.<SysMenu>query().lambda()
.eq(SysMenu::getModelId, menu.getModelId()) .eq(SysMenu::getViewId, menu.getViewId())
.eq(SysMenu::getDeleteStatus, CommonConstants.ONE_STRING)); .eq(SysMenu::getDeleteStatus, CommonConstants.ONE_STRING));
if (modelCount > 0) { if (modelCount > 0) {
return R.failed("已存在对应菜单的权限维度"); return R.failed("已存在对应菜单的权限维度");
} }
//是否开关为是的话,modelId只能有一个
boolean errorFlag = isOpenCheck(menu);
if (errorFlag) {
return R.failed("只能存在一个开关状态为开的表单ID");
}
//判断菜单是否为一级菜单 //判断菜单是否为一级菜单
if (Common.isNotNull(menu.getMenuName()) && Common.isEmpty(menu.getMenuNameParent())) { if (Common.isNotNull(menu.getMenuName()) && Common.isEmpty(menu.getMenuNameParent())) {
//一级菜单的上级菜单id为0 //一级菜单的上级菜单id为0
...@@ -86,6 +96,11 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl ...@@ -86,6 +96,11 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
@Override @Override
public R<Boolean> updateMenu(SysMenu menu) { public R<Boolean> updateMenu(SysMenu menu) {
//是否开关为是的话,modelId只能有一个
boolean errorFlag = isOpenCheck(menu);
if (errorFlag) {
return R.failed("只能存在一个开关状态为开的表单ID");
}
//错误信息 //错误信息
StringBuilder errorStr = new StringBuilder(); StringBuilder errorStr = new StringBuilder();
//权限维度 //权限维度
...@@ -118,4 +133,25 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl ...@@ -118,4 +133,25 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
} }
} }
public boolean isOpenCheck(SysMenu menu) {
if (Common.isNotNull(menu.getIsOpen()) && CommonConstants.ZERO_STRING.equals(menu.getIsOpen())) {
if (Common.isNotNull(menu.getId())) {
long modelCount = baseMapper.selectCount(Wrappers.<SysMenu>query().lambda()
.eq(SysMenu::getModelId, menu.getModelId())
.eq(SysMenu::getDeleteStatus, CommonConstants.ONE_STRING)
.eq(SysMenu::getIsOpen, CommonConstants.ZERO_STRING)
.ne(SysMenu::getId, menu.getId()));
return modelCount > 0;
}else {
long modelCount = baseMapper.selectCount(Wrappers.<SysMenu>query().lambda()
.eq(SysMenu::getModelId, menu.getModelId())
.eq(SysMenu::getDeleteStatus, CommonConstants.ONE_STRING)
.eq(SysMenu::getIsOpen, CommonConstants.ZERO_STRING));
return modelCount > 0;
}
} else {
return false;
}
}
} }
...@@ -158,7 +158,7 @@ public class SysUserPermissionServiceImpl extends ServiceImpl<SysUserPermissionM ...@@ -158,7 +158,7 @@ public class SysUserPermissionServiceImpl extends ServiceImpl<SysUserPermissionM
if (CommonConstants.ONE_STRING.equals(user.getId())) { if (CommonConstants.ONE_STRING.equals(user.getId())) {
iPage = baseMapper.selectContractVO(page, searchVo.getName()); iPage = baseMapper.selectContractVO(page, searchVo.getName());
} else { } else {
iPage = baseMapper.selectContractSimpleVO(page, searchVo.getName(),searchVo.getName(),searchVo.getType()); iPage = baseMapper.selectContractSimpleVO(page, user.getUsername(),searchVo.getName(),searchVo.getType());
} }
} else if (CommonConstants.EIGHT_STRING.equals(searchVo.getType()) || CommonConstants.NINE_STRING.equals(searchVo.getType())) { } else if (CommonConstants.EIGHT_STRING.equals(searchVo.getType()) || CommonConstants.NINE_STRING.equals(searchVo.getType())) {
//部门&&收入归属权限 //部门&&收入归属权限
...@@ -168,7 +168,7 @@ public class SysUserPermissionServiceImpl extends ServiceImpl<SysUserPermissionM ...@@ -168,7 +168,7 @@ public class SysUserPermissionServiceImpl extends ServiceImpl<SysUserPermissionM
if (CommonConstants.ONE_STRING.equals(user.getId())) { if (CommonConstants.ONE_STRING.equals(user.getId())) {
iPage = baseMapper.selectSettleVO(page, searchVo.getName()); iPage = baseMapper.selectSettleVO(page, searchVo.getName());
} else { } else {
iPage = baseMapper.selectContractSimpleVO(page, searchVo.getName(),searchVo.getName(),searchVo.getType()); iPage = baseMapper.selectContractSimpleVO(page, user.getUsername(),searchVo.getName(),searchVo.getType());
} }
} }
return iPage; return iPage;
...@@ -259,6 +259,7 @@ public class SysUserPermissionServiceImpl extends ServiceImpl<SysUserPermissionM ...@@ -259,6 +259,7 @@ public class SysUserPermissionServiceImpl extends ServiceImpl<SysUserPermissionM
YifuUser user = SecurityUtils.getUser(); YifuUser user = SecurityUtils.getUser();
SysUserPermission permission; SysUserPermission permission;
List<SysUserInfo> userInfo; List<SysUserInfo> userInfo;
String domainId;
try { try {
// 执行数据插入操作 组装 // 执行数据插入操作 组装
...@@ -328,6 +329,7 @@ public class SysUserPermissionServiceImpl extends ServiceImpl<SysUserPermissionM ...@@ -328,6 +329,7 @@ public class SysUserPermissionServiceImpl extends ServiceImpl<SysUserPermissionM
errorMessageList.add(new ErrorMessage(excel.getRowIndex(), "系统中已经存在该用户对应的名称权限维度", excel)); errorMessageList.add(new ErrorMessage(excel.getRowIndex(), "系统中已经存在该用户对应的名称权限维度", excel));
continue; continue;
} }
insert.setCode(null);
} else { } else {
//判断对应维度的编码是否存在 //判断对应维度的编码是否存在
Integer count = this.checkExit(insert.getPermissionType(), excel.getCode()); Integer count = this.checkExit(insert.getPermissionType(), excel.getCode());
...@@ -358,6 +360,15 @@ public class SysUserPermissionServiceImpl extends ServiceImpl<SysUserPermissionM ...@@ -358,6 +360,15 @@ public class SysUserPermissionServiceImpl extends ServiceImpl<SysUserPermissionM
continue; continue;
} }
} }
//项目权限的时候赋值项目id
if (CommonConstants.FIVE_STRING.equals(insert.getPermissionType())) {
domainId = baseMapper.selectSettleByCode(insert.getCode());
insert.setDomainId(domainId);
}
if (!CommonConstants.EIGHT_STRING.equals(insert.getPermissionType()) &&
!CommonConstants.NINE_STRING.equals(insert.getPermissionType())) {
insert.setIsContains(null);
}
// 插入数据 // 插入数据
insertExcel(insert); insertExcel(insert);
} }
...@@ -369,7 +380,7 @@ public class SysUserPermissionServiceImpl extends ServiceImpl<SysUserPermissionM ...@@ -369,7 +380,7 @@ public class SysUserPermissionServiceImpl extends ServiceImpl<SysUserPermissionM
/** /**
* 插入excel bad record * 插入excel bad record
*/ */
private void insertExcel(SysUserPermission insert ) { private void insertExcel(SysUserPermission insert) {
//转化是否含下级 //转化是否含下级
if (Common.isNotNull(insert.getIsContains())) { if (Common.isNotNull(insert.getIsContains())) {
if (CommonConstants.IS_TRUE.equals(insert.getIsContains())) { if (CommonConstants.IS_TRUE.equals(insert.getIsContains())) {
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
<result property="createName" column="CREATE_NAME"/> <result property="createName" column="CREATE_NAME"/>
<result property="createTime" column="CREATE_TIME"/> <result property="createTime" column="CREATE_TIME"/>
<result property="updateTime" column="UPDATE_TIME"/> <result property="updateTime" column="UPDATE_TIME"/>
<result property="isOpen" column="IS_OPEN"/>
</resultMap> </resultMap>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
a.ID, a.ID,
...@@ -46,6 +47,8 @@ ...@@ -46,6 +47,8 @@
a.BU_ID, a.BU_ID,
a.LINE_ID, a.LINE_ID,
a.DEPT_ID, a.DEPT_ID,
a.IS_OPEN,
a.VIEW_ID,
a.CREATE_TIME a.CREATE_TIME
</sql> </sql>
<sql id="sysMenu_where"> <sql id="sysMenu_where">
...@@ -83,6 +86,13 @@ ...@@ -83,6 +86,13 @@
WHERE a.fd_id = #{modelId} WHERE a.fd_id = #{modelId}
</select> </select>
<select id="selectViewId" resultType="java.lang.Long">
SELECT
count(1)
FROM modeling_app_collection_view a
WHERE a.fd_model_id = #{modelId} and a.fd_id = #{viewId}
</select>
<select id="selectColumnList" resultType="java.lang.String"> <select id="selectColumnList" resultType="java.lang.String">
SELECT SELECT
a.fd_column a.fd_column
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
<resultMap id="nameAndCodeMap" type="com.yifu.cloud.plus.v1.yifu.permission.vo.SysUserDeptVo"> <resultMap id="nameAndCodeMap" type="com.yifu.cloud.plus.v1.yifu.permission.vo.SysUserDeptVo">
<result property="name" column="name"/> <result property="name" column="name"/>
<result property="code" column="code"/> <result property="code" column="code"/>
<result property="domainId" column="domainId"/>
</resultMap> </resultMap>
<resultMap id="dictMap" type="com.yifu.cloud.plus.v1.yifu.permission.vo.SysDictVo"> <resultMap id="dictMap" type="com.yifu.cloud.plus.v1.yifu.permission.vo.SysDictVo">
...@@ -156,7 +157,7 @@ ...@@ -156,7 +157,7 @@
<select id="selectSettleVO" resultMap="nameAndCodeMap"> <select id="selectSettleVO" resultMap="nameAndCodeMap">
SELECT SELECT
a.fd_3a37fe508071fe code,a.fd_3a2b38c61ef9aa name a.fd_3a37fe508071fe code,a.fd_3a2b38c61ef9aa name,a.fd_id domainId
from ekp_24a8e6a7fc143bb8c48a a from ekp_24a8e6a7fc143bb8c48a a
where 1=1 where 1=1
<if test="name != null and name.trim() != ''"> <if test="name != null and name.trim() != ''">
...@@ -164,12 +165,19 @@ ...@@ -164,12 +165,19 @@
</if> </if>
</select> </select>
<!--根据项目编码查询id-->
<select id="selectSettleByCode" resultType="java.lang.String">
SELECT
a.fd_id
from ekp_24a8e6a7fc143bb8c48a a where a.fd_3a37fe508071fe = #{code} limit 1
</select>
<select id="selectContractSimpleVO" resultMap="nameAndCodeMap"> <select id="selectContractSimpleVO" resultMap="nameAndCodeMap">
SELECT SELECT
a.NAME, a.NAME,
a.CODE a.CODE
from sys_user_permission a from sys_user_permission a
where a.EMP_LOGIN_NAME = #{loginName} and a.PERMISSION_TYPE = #{type} where a.EMP_LOGIN_NAME = #{loginName} and a.PERMISSION_TYPE = #{type} and a.PERMISSION_STATUS = '0'
<if test="name != null and name.trim() != ''"> <if test="name != null and name.trim() != ''">
AND (a.NAME like concat('%',#{name},'%') or a.CODE like concat('%',#{name},'%')) AND (a.NAME like concat('%',#{name},'%') or a.CODE like concat('%',#{name},'%'))
</if> </if>
......
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