新增角色菜单临时接口
This commit is contained in:
@@ -23,4 +23,9 @@ public class SysMenuDAO {
|
||||
return sysMenuMapper.selectMenuAll(parentIds, platformType);
|
||||
}
|
||||
|
||||
public Long addMenu(SysMenuDO param){
|
||||
sysMenuMapper.insertSelective(param);
|
||||
return param.getId();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ package com.cool.store.dao;
|
||||
import com.cool.store.entity.SysRoleDO;
|
||||
import com.cool.store.enums.DataSourceEnum;
|
||||
import com.cool.store.mapper.SysRoleMapper;
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Repository;
|
||||
@@ -50,4 +52,16 @@ public class SysRoleDAO {
|
||||
}
|
||||
return sysRoleMapper.getRoleByName(roleName, dataSource.getCode());
|
||||
}
|
||||
|
||||
public Page<SysRoleDO> getRolePage(Integer pageNum, Integer pageSize){
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
return sysRoleMapper.getRolePage();
|
||||
}
|
||||
|
||||
public SysRoleDO getRoleDetail(String roleId){
|
||||
if(StringUtils.isBlank(roleId)){
|
||||
return null;
|
||||
}
|
||||
return sysRoleMapper.getRoleDetail(roleId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,13 @@ package com.cool.store.dao;
|
||||
|
||||
import com.aliyun.openservices.shade.org.apache.commons.lang3.StringUtils;
|
||||
import com.cool.store.entity.SysRoleMenuDO;
|
||||
import com.cool.store.enums.PlatFormTypeEnum;
|
||||
import com.cool.store.mapper.SysRoleMenuMapper;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -33,4 +35,17 @@ public class SysRoleMenuDAO {
|
||||
return sysRoleMenuMapper.getRoleMenuByRoleId(roleId, platform);
|
||||
}
|
||||
|
||||
public Integer updateRoleAuth(String roleId, List<Long> menuIds){
|
||||
//先删后增
|
||||
sysRoleMenuMapper.deleteRoleAuth(roleId, PlatFormTypeEnum.PC.getCode());
|
||||
List<SysRoleMenuDO> insertList = new ArrayList<>();
|
||||
for (Long menuId : menuIds) {
|
||||
SysRoleMenuDO insert = new SysRoleMenuDO();
|
||||
insert.setMenuId(menuId);
|
||||
insert.setRoleId(roleId);
|
||||
insertList.add(insert);
|
||||
}
|
||||
return sysRoleMenuMapper.batchInsert(insertList);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.cool.store.mapper;
|
||||
|
||||
import com.cool.store.entity.SysRoleDO;
|
||||
import com.github.pagehelper.Page;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
@@ -40,4 +41,17 @@ public interface SysRoleMapper {
|
||||
* @return
|
||||
*/
|
||||
SysRoleDO getRoleByName(@Param("roleName") String roleName, @Param("roleType")Integer roleType);
|
||||
|
||||
/**
|
||||
* 角色分页
|
||||
* @return
|
||||
*/
|
||||
Page<SysRoleDO> getRolePage();
|
||||
|
||||
/**
|
||||
* 获取角色详情
|
||||
* @param roleId
|
||||
* @return
|
||||
*/
|
||||
SysRoleDO getRoleDetail(@Param("roleId") String roleId);
|
||||
}
|
||||
@@ -16,7 +16,7 @@ public interface SysRoleMenuMapper {
|
||||
* 会对传进来的字段做判空处理,如果字段为空,则使用数据库默认字段或者null
|
||||
* dateTime:2023-05-19 03:01
|
||||
*/
|
||||
int insertSelective(@Param("record") SysRoleMenuDO record);
|
||||
int batchInsert(@Param("recordList") List<SysRoleMenuDO> recordList);
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -32,4 +32,11 @@ public interface SysRoleMenuMapper {
|
||||
* @return
|
||||
*/
|
||||
List<SysRoleMenuDO> getRoleMenuByRoleId(@Param("roleId")String roleId, @Param("platform")String platform);
|
||||
|
||||
/**
|
||||
* 删除角色权限
|
||||
* @param roleId
|
||||
* @return
|
||||
*/
|
||||
Integer deleteRoleAuth(@Param("roleId")String roleId, @Param("platform")String platform);
|
||||
}
|
||||
@@ -28,7 +28,7 @@
|
||||
id, parent_id, code, name, alias, path, perms, source, sort, category, action, remark,
|
||||
platform, is_deleted, type, target, component, icon, menu_type, env, common_functions_icon
|
||||
</sql>
|
||||
<insert id="insertSelective" keyColumn="id" keyProperty="record.id" useGeneratedKeys="true">
|
||||
<insert id="insertSelective" keyColumn="id" keyProperty="id" useGeneratedKeys="true">
|
||||
insert into sys_menu
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="parentId != null">
|
||||
|
||||
@@ -138,4 +138,20 @@
|
||||
where
|
||||
role_name = #{roleName} and role_type = #{roleType} and deleted = 0 limit 1
|
||||
</select>
|
||||
|
||||
<select id="getRolePage" resultMap="BaseResultMap">
|
||||
select
|
||||
<include refid="Base_Column_List"/>
|
||||
from
|
||||
sys_role
|
||||
</select>
|
||||
|
||||
<select id="getRoleDetail" resultMap="BaseResultMap">
|
||||
select
|
||||
<include refid="Base_Column_List"/>
|
||||
from
|
||||
sys_role
|
||||
where
|
||||
role_id = #{roleId} deleted = 0
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -10,30 +10,32 @@
|
||||
<sql id="Base_Column_List">
|
||||
id, menu_id, role_id, platform
|
||||
</sql>
|
||||
<insert id="insertSelective" keyColumn="id" keyProperty="record.id" useGeneratedKeys="true">
|
||||
insert into sys_role_menu
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="record.menuId != null">
|
||||
menu_id,
|
||||
</if>
|
||||
<if test="record.roleId != null">
|
||||
role_id,
|
||||
</if>
|
||||
<if test="record.platform != null">
|
||||
platform,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="record.menuId != null">
|
||||
#{record.menuId},
|
||||
</if>
|
||||
<if test="record.roleId != null">
|
||||
#{record.roleId},
|
||||
</if>
|
||||
<if test="record.platform != null">
|
||||
#{record.platform},
|
||||
</if>
|
||||
</trim>
|
||||
<insert id="batchInsert">
|
||||
<foreach collection="recordList" item="record" separator=";">
|
||||
insert into sys_role_menu
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="record.menuId != null">
|
||||
menu_id,
|
||||
</if>
|
||||
<if test="record.roleId != null">
|
||||
role_id,
|
||||
</if>
|
||||
<if test="record.platform != null">
|
||||
platform,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="record.menuId != null">
|
||||
#{record.menuId},
|
||||
</if>
|
||||
<if test="record.roleId != null">
|
||||
#{record.roleId},
|
||||
</if>
|
||||
<if test="record.platform != null">
|
||||
#{record.platform},
|
||||
</if>
|
||||
</trim>
|
||||
</foreach>
|
||||
</insert>
|
||||
<update id="updateByPrimaryKeySelective">
|
||||
update sys_role_menu
|
||||
@@ -59,4 +61,8 @@
|
||||
where
|
||||
role_id=#{roleId} and platform=#{platform}
|
||||
</select>
|
||||
|
||||
<delete id="deleteRoleAuth">
|
||||
delete from sys_role_menu where role_id=#{roleId} and platform=#{platform}
|
||||
</delete>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user