Commit 550f231d by guojuxing

权限添加部门权限

parent 0ab8addc
package com.gic.auth.dto;
import java.io.Serializable;
import java.util.Date;
public class MenuAuthDepartDTO implements Serializable{
private static final long serialVersionUID = 4195293064485615589L;
/**
* ID
*/
private Integer menuDepartId;
/**
* 菜单code
*/
private String menuCode;
/**
* 部门code
*/
private String departCode;
/**
* 部门name
*/
private String departName;
/**
* 职位code
*/
private String positionCode;
/**
* 职位name
*/
private String positionName;
/**
* 1:有效 0:无效
*/
private Integer status;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date updateTime;
public Integer getMenuDepartId() {
return menuDepartId;
}
public MenuAuthDepartDTO setMenuDepartId(Integer menuDepartId) {
this.menuDepartId = menuDepartId;
return this;
}
public String getMenuCode() {
return menuCode;
}
public MenuAuthDepartDTO setMenuCode(String menuCode) {
this.menuCode = menuCode;
return this;
}
public String getDepartCode() {
return departCode;
}
public MenuAuthDepartDTO setDepartCode(String departCode) {
this.departCode = departCode;
return this;
}
public String getDepartName() {
return departName;
}
public MenuAuthDepartDTO setDepartName(String departName) {
this.departName = departName;
return this;
}
public String getPositionCode() {
return positionCode;
}
public MenuAuthDepartDTO setPositionCode(String positionCode) {
this.positionCode = positionCode;
return this;
}
public String getPositionName() {
return positionName;
}
public MenuAuthDepartDTO setPositionName(String positionName) {
this.positionName = positionName;
return this;
}
public Integer getStatus() {
return status;
}
public MenuAuthDepartDTO setStatus(Integer status) {
this.status = status;
return this;
}
public Date getCreateTime() {
return createTime;
}
public MenuAuthDepartDTO setCreateTime(Date createTime) {
this.createTime = createTime;
return this;
}
public Date getUpdateTime() {
return updateTime;
}
public MenuAuthDepartDTO setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
return this;
}
}
......@@ -168,6 +168,16 @@ public class MenuDTO implements Serializable {
*/
private Integer adminOnlySign;
/**
* 1:管理员权限集 2:商户级超管及达摩侧人员 3:仅达摩侧人员
*/
private Integer authType;
/**
* 部门职位
*/
private List<MenuAuthDepartDTO> menuAuthDepartList;
public Integer getMenuId() {
return menuId;
}
......@@ -327,4 +337,22 @@ public class MenuDTO implements Serializable {
public void setAdminOnlySign(Integer adminOnlySign) {
this.adminOnlySign = adminOnlySign;
}
public List<MenuAuthDepartDTO> getMenuAuthDepartList() {
return menuAuthDepartList;
}
public MenuDTO setMenuAuthDepartList(List<MenuAuthDepartDTO> menuAuthDepartList) {
this.menuAuthDepartList = menuAuthDepartList;
return this;
}
public Integer getAuthType() {
return authType;
}
public MenuDTO setAuthType(Integer authType) {
this.authType = authType;
return this;
}
}
package com.gic.auth.dao.mapper;
import com.gic.auth.dto.MenuAuthDepartDTO;
import com.gic.auth.entity.TabSysMenuAuthDepart;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface TabSysMenuAuthDepartMapper {
/**
* 根据主键删除
*
* @param menuDepartId 主键
* @return 更新条目数
*/
int deleteByPrimaryKey(Integer menuDepartId);
/**
* 插入一条记录
*
* @param record 实体对象
* @return 更新条目数
*/
int insert(TabSysMenuAuthDepart record);
/**
* 动态插入一条记录
*
* @param record 实体对象
* @return 更新条目数
*/
int insertSelective(TabSysMenuAuthDepart record);
/**
* 根据主键查询
*
* @param menuDepartId 主键
* @return 实体对象
*/
TabSysMenuAuthDepart selectByPrimaryKey(Integer menuDepartId);
/**
* 根据主键动态更新记录
*
* @param record 实体对象
* @return 更新条目数
*/
int updateByPrimaryKeySelective(TabSysMenuAuthDepart record);
/**
* 根据主键更新记录
*
* @param record 实体对象
* @return 更新条目数
*/
int updateByPrimaryKey(TabSysMenuAuthDepart record);
void saveFetch(@Param("list") List<MenuAuthDepartDTO> list);
void deleteByMenuCode(String menuCode);
List<TabSysMenuAuthDepart> listAuthDepartByMenuCode(String menuCode);
}
\ No newline at end of file
......@@ -106,6 +106,11 @@ public class TabSysMenu {
*/
private Integer adminOnlySign;
/**
* 1:管理员权限集 2:商户级超管及达摩侧人员 3:仅达摩侧人员
*/
private Integer authType;
public Integer getMenuId() {
return menuId;
}
......@@ -265,4 +270,13 @@ public class TabSysMenu {
public void setAdminOnlySign(Integer adminOnlySign) {
this.adminOnlySign = adminOnlySign;
}
public Integer getAuthType() {
return authType;
}
public TabSysMenu setAuthType(Integer authType) {
this.authType = authType;
return this;
}
}
\ No newline at end of file
package com.gic.auth.entity;
import java.util.Date;
/**
* tab_sys_menu_auth_depart
*/
public class TabSysMenuAuthDepart {
/**
* ID
*/
private Integer menuDepartId;
/**
* 菜单code
*/
private String menuCode;
/**
* 部门code
*/
private String departCode;
/**
* 部门name
*/
private String departName;
/**
* 职位code
*/
private String positionCode;
/**
* 职位name
*/
private String positionName;
/**
* 1:有效 0:无效
*/
private Integer status;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date updateTime;
public Integer getMenuDepartId() {
return menuDepartId;
}
public TabSysMenuAuthDepart setMenuDepartId(Integer menuDepartId) {
this.menuDepartId = menuDepartId;
return this;
}
public String getMenuCode() {
return menuCode;
}
public TabSysMenuAuthDepart setMenuCode(String menuCode) {
this.menuCode = menuCode;
return this;
}
public String getDepartCode() {
return departCode;
}
public TabSysMenuAuthDepart setDepartCode(String departCode) {
this.departCode = departCode;
return this;
}
public String getDepartName() {
return departName;
}
public TabSysMenuAuthDepart setDepartName(String departName) {
this.departName = departName;
return this;
}
public String getPositionCode() {
return positionCode;
}
public TabSysMenuAuthDepart setPositionCode(String positionCode) {
this.positionCode = positionCode;
return this;
}
public String getPositionName() {
return positionName;
}
public TabSysMenuAuthDepart setPositionName(String positionName) {
this.positionName = positionName;
return this;
}
public Integer getStatus() {
return status;
}
public TabSysMenuAuthDepart setStatus(Integer status) {
this.status = status;
return this;
}
public Date getCreateTime() {
return createTime;
}
public TabSysMenuAuthDepart setCreateTime(Date createTime) {
this.createTime = createTime;
return this;
}
public Date getUpdateTime() {
return updateTime;
}
public TabSysMenuAuthDepart setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
return this;
}
}
\ No newline at end of file
package com.gic.auth.service;
import com.gic.auth.dto.MenuAuthDepartDTO;
import com.gic.auth.entity.TabSysMenuAuthDepart;
import java.util.List;
public interface MenuAuthDepartService {
/**
* 批量新增部门职位
* @Title: saveFetch

* @Description:

* @author guojuxing
* @param list

* @return void


*/
void saveFetch(List<MenuAuthDepartDTO> list);
/**
* 查询菜单的所有部门职位
* @Title: listAuthDepartByMenuCode

* @Description:

* @author guojuxing
* @param menuCode

* @return java.util.List<com.gic.auth.entity.TabSysMenuAuthDepart>


*/
List<TabSysMenuAuthDepart> listAuthDepartByMenuCode(String menuCode);
}
package com.gic.auth.service.impl;
import com.gic.auth.dao.mapper.TabSysMenuAuthDepartMapper;
import com.gic.auth.dto.MenuAuthDepartDTO;
import com.gic.auth.entity.TabSysMenuAuthDepart;
import com.gic.auth.service.MenuAuthDepartService;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service("menuAuthDepartService")
public class MenuAuthDepartServiceImpl implements MenuAuthDepartService{
@Autowired
private TabSysMenuAuthDepartMapper tabSysMenuAuthDepartMapper;
@Override
public void saveFetch(List<MenuAuthDepartDTO> list) {
if (CollectionUtils.isNotEmpty(list)) {
tabSysMenuAuthDepartMapper.deleteByMenuCode(list.get(0).getMenuCode());
tabSysMenuAuthDepartMapper.saveFetch(list);
}
}
@Override
public List<TabSysMenuAuthDepart> listAuthDepartByMenuCode(String menuCode) {
return tabSysMenuAuthDepartMapper.listAuthDepartByMenuCode(menuCode);
}
}
......@@ -3,7 +3,7 @@ package com.gic.auth.service.outer.impl;
import java.util.*;
import java.util.stream.Collectors;
import com.gic.auth.entity.TabSysBusinessFrontRes;
import com.gic.auth.entity.*;
import com.gic.enterprise.dto.EnterpriseDTO;
import com.gic.enterprise.dto.EnterpriseResourceRelDTO;
import com.gic.enterprise.service.EnterpriseApiService;
......@@ -23,9 +23,6 @@ import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.auth.constant.*;
import com.gic.auth.dto.*;
import com.gic.auth.entity.TabSysMenu;
import com.gic.auth.entity.TabSysMenuItem;
import com.gic.auth.entity.TabSysUser;
import com.gic.auth.qo.AuthItemSaveQO;
import com.gic.auth.qo.MenuListQO;
import com.gic.auth.qo.MenuOperationItemListQO;
......@@ -61,6 +58,8 @@ public class MenuApiServiceImpl implements MenuApiService {
private EnterpriseApiService enterpriseApiService;
@Autowired
private BusinessFrontResService businessFrontResService;
@Autowired
private MenuAuthDepartService menuAuthDepartService;
@Override
public ServiceResponse<List<MenuDTO>> listByMenuIdList(List<Integer> menuIdList) {
......@@ -339,7 +338,9 @@ public class MenuApiServiceImpl implements MenuApiService {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "code:" + menuDTO.getMenuCode() + "重复");
}
setMenuAuthType(menuDTO);
menuService.updatePage(menuDTO);
menuAuthDepartService.saveFetch(menuDTO.getMenuAuthDepartList());
//同时更新子集的父级code数据
menuService.updateParentCodeByParentId(menuDTO.getMenuId(), menuDTO.getMenuCode());
......@@ -409,7 +410,14 @@ public class MenuApiServiceImpl implements MenuApiService {
if (record == null) {
return ServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "主键参数有误,查无数据");
}
return ServiceResponse.success(EntityUtil.changeEntityNew(MenuDTO.class, record));
MenuDTO menuDTO = EntityUtil.changeEntityNew(MenuDTO.class, record);
if (record.getAuthType().intValue() != 1) {
//添加部门职位数据
List<TabSysMenuAuthDepart> list = menuAuthDepartService
.listAuthDepartByMenuCode(record.getMenuCode());
menuDTO.setMenuAuthDepartList(EntityUtil.changeEntityListNew(MenuAuthDepartDTO.class, list));
}
return ServiceResponse.success(menuDTO);
}
@Transactional(rollbackFor = Exception.class)
......@@ -638,10 +646,36 @@ public class MenuApiServiceImpl implements MenuApiService {
setMenuVersion(menuDTO);
setNormalFieldValue(menuDTO);
setMenuAuthType(menuDTO);
menuService.savePage(menuDTO);
menuAuthDepartService.saveFetch(menuDTO.getMenuAuthDepartList());
return ServiceResponse.success();
}
/**
* 奢姿权限适用字段数据
* @param menuDTO
* @return
*/
private void setMenuAuthType(MenuDTO menuDTO) {
Integer authType = menuDTO.getAuthType();
if (authType == null) {
authType = 1;
}
menuDTO.setAuthType(authType);
if (authType != 1) {
List<MenuAuthDepartDTO> list = menuDTO.getMenuAuthDepartList();
if (CollectionUtils.isNotEmpty(list)) {
Date now = new Date();
menuDTO.setMenuAuthDepartList(
list.stream().map(e -> e.setMenuCode(menuDTO.getMenuCode())
.setStatus(1)
.setCreateTime(now)
.setUpdateTime(now)).collect(Collectors.toList()));
}
}
}
private ServiceResponse<Integer> saveChildPage(MenuDTO menuDTO, Class clazz) {
TabSysMenu record = menuService.getMenuById(menuDTO.getParentId());
if (record == null) {
......@@ -664,8 +698,10 @@ public class MenuApiServiceImpl implements MenuApiService {
}
}
setMenuVersion(menuDTO);
setMenuAuthType(menuDTO);
Integer menuId = menuService.savePage(menuDTO);
menuAuthDepartService.saveFetch(menuDTO.getMenuAuthDepartList());
return ServiceResponse.success(menuId);
}
......@@ -713,7 +749,9 @@ public class MenuApiServiceImpl implements MenuApiService {
}
}
setMenuVersion(menuDTO);
setMenuAuthType(menuDTO);
menuService.updatePage(menuDTO);
menuAuthDepartService.saveFetch(menuDTO.getMenuAuthDepartList());
//同时更新子集的父级code数据
menuService.updateParentCodeByParentId(menuDTO.getMenuId(), menuDTO.getMenuCode());
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.gic.auth.dao.mapper.TabSysMenuAuthDepartMapper">
<resultMap id="BaseResultMap" type="com.gic.auth.entity.TabSysMenuAuthDepart">
<id column="menu_depart_id" jdbcType="INTEGER" property="menuDepartId" />
<result column="menu_code" jdbcType="VARCHAR" property="menuCode" />
<result column="depart_code" jdbcType="VARCHAR" property="departCode" />
<result column="depart_name" jdbcType="VARCHAR" property="departName" />
<result column="position_code" jdbcType="VARCHAR" property="positionCode" />
<result column="position_name" jdbcType="VARCHAR" property="positionName" />
<result column="status" jdbcType="INTEGER" property="status" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
</resultMap>
<sql id="Base_Column_List">
menu_depart_id, menu_code, depart_code, depart_name, position_code, position_name,
status, create_time, update_time
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from tab_sys_menu_auth_depart
where menu_depart_id = #{menuDepartId,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from tab_sys_menu_auth_depart
where menu_depart_id = #{menuDepartId,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.gic.auth.entity.TabSysMenuAuthDepart">
insert into tab_sys_menu_auth_depart (menu_depart_id, menu_code, depart_code,
depart_name, position_code, position_name,
status, create_time, update_time
)
values (#{menuDepartId,jdbcType=INTEGER}, #{menuCode,jdbcType=VARCHAR}, #{departCode,jdbcType=VARCHAR},
#{departName,jdbcType=VARCHAR}, #{positionCode,jdbcType=VARCHAR}, #{positionName,jdbcType=VARCHAR},
#{status,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}
)
</insert>
<insert id="insertSelective" parameterType="com.gic.auth.entity.TabSysMenuAuthDepart">
insert into tab_sys_menu_auth_depart
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="menuDepartId != null">
menu_depart_id,
</if>
<if test="menuCode != null">
menu_code,
</if>
<if test="departCode != null">
depart_code,
</if>
<if test="departName != null">
depart_name,
</if>
<if test="positionCode != null">
position_code,
</if>
<if test="positionName != null">
position_name,
</if>
<if test="status != null">
status,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="menuDepartId != null">
#{menuDepartId,jdbcType=INTEGER},
</if>
<if test="menuCode != null">
#{menuCode,jdbcType=VARCHAR},
</if>
<if test="departCode != null">
#{departCode,jdbcType=VARCHAR},
</if>
<if test="departName != null">
#{departName,jdbcType=VARCHAR},
</if>
<if test="positionCode != null">
#{positionCode,jdbcType=VARCHAR},
</if>
<if test="positionName != null">
#{positionName,jdbcType=VARCHAR},
</if>
<if test="status != null">
#{status,jdbcType=INTEGER},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.gic.auth.entity.TabSysMenuAuthDepart">
update tab_sys_menu_auth_depart
<set>
<if test="menuCode != null">
menu_code = #{menuCode,jdbcType=VARCHAR},
</if>
<if test="departCode != null">
depart_code = #{departCode,jdbcType=VARCHAR},
</if>
<if test="departName != null">
depart_name = #{departName,jdbcType=VARCHAR},
</if>
<if test="positionCode != null">
position_code = #{positionCode,jdbcType=VARCHAR},
</if>
<if test="positionName != null">
position_name = #{positionName,jdbcType=VARCHAR},
</if>
<if test="status != null">
status = #{status,jdbcType=INTEGER},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
</set>
where menu_depart_id = #{menuDepartId,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.gic.auth.entity.TabSysMenuAuthDepart">
update tab_sys_menu_auth_depart
set menu_code = #{menuCode,jdbcType=VARCHAR},
depart_code = #{departCode,jdbcType=VARCHAR},
depart_name = #{departName,jdbcType=VARCHAR},
position_code = #{positionCode,jdbcType=VARCHAR},
position_name = #{positionName,jdbcType=VARCHAR},
status = #{status,jdbcType=INTEGER},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP}
where menu_depart_id = #{menuDepartId,jdbcType=INTEGER}
</update>
<insert id="saveFetch" parameterType="java.util.List">
insert into tab_sys_menu_auth_depart (menu_depart_id, menu_code, depart_code,
depart_name, position_code, position_name,
status, create_time, update_time
)
values
<foreach collection="list" item="item" index="index" separator=",">
(
#{item.menuDepartId},
#{item.menuCode},
#{item.departCode},
#{item.departName},
#{item.positionCode},
#{item.positionName},
#{item.status},
#{item.createTime},
#{item.updateTime}
)
</foreach>
</insert>
<update id="deleteByMenuCode">
update tab_sys_menu_auth_depart set status = 0
where status = 1
and menu_code = #{menuCode}
</update>
<select id="listAuthDepartByMenuCode" resultMap="BaseResultMap">
select <include refid="Base_Column_List"></include>
from tab_sys_menu_auth_depart
where menu_code = #{menuCode}
and status = 1
</select>
</mapper>
\ No newline at end of file
......@@ -22,11 +22,12 @@
<result column="menu_version_name" jdbcType="VARCHAR" property="menuVersionName" />
<result column="project_url_for_web" jdbcType="VARCHAR" property="projectUrlForWeb" />
<result column="admin_only_sign" jdbcType="INTEGER" property="adminOnlySign" />
<result column="auth_type" jdbcType="INTEGER" property="authType" />
</resultMap>
<sql id="Base_Column_List">
menu_id, menu_name, project, menu_url, parent_id, target, icon_url, sort, status,
create_time, update_time, level, is_show, menu_code, parent_code, menu_version, menu_type,
menu_version_name, project_url_for_web, admin_only_sign
menu_version_name, project_url_for_web, admin_only_sign, auth_type
</sql>
<sql id="tree_filter">
and menu_type != 2
......@@ -57,14 +58,14 @@
create_time, update_time, level,
is_show, menu_code, parent_code,
menu_version, menu_type, menu_version_name,
project_url_for_web, admin_only_sign)
project_url_for_web, admin_only_sign, auth_type)
values (#{menuId,jdbcType=INTEGER}, #{menuName,jdbcType=VARCHAR}, #{project,jdbcType=VARCHAR},
#{menuUrl,jdbcType=VARCHAR}, #{parentId,jdbcType=INTEGER}, #{target,jdbcType=INTEGER},
#{iconUrl,jdbcType=VARCHAR}, #{sort,jdbcType=INTEGER}, #{status,jdbcType=INTEGER},
#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, #{level,jdbcType=INTEGER},
#{isShow,jdbcType=INTEGER}, #{menuCode,jdbcType=VARCHAR}, #{parentCode,jdbcType=VARCHAR},
#{menuVersion,jdbcType=VARCHAR}, #{menuType,jdbcType=INTEGER}, #{menuVersionName,jdbcType=VARCHAR},
#{projectUrlForWeb,jdbcType=VARCHAR}, #{adminOnlySign,jdbcType=INTEGER})
#{projectUrlForWeb,jdbcType=VARCHAR}, #{adminOnlySign,jdbcType=INTEGER}, #{authType,jdbcType=INTEGER})
</insert>
<insert id="insertSelective" keyProperty="menuId" parameterType="com.gic.auth.entity.TabSysMenu" useGeneratedKeys="true">
insert into tab_sys_menu
......@@ -129,6 +130,9 @@
<if test="adminOnlySign != null">
admin_only_sign,
</if>
<if test="authType != null">
auth_type,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="menuId != null">
......@@ -191,6 +195,9 @@
<if test="adminOnlySign != null">
#{adminOnlySign,jdbcType=INTEGER},
</if>
<if test="authType != null">
#{authType,jdbcType=INTEGER},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.gic.auth.entity.TabSysMenu">
......@@ -253,6 +260,9 @@
<if test="adminOnlySign != null">
admin_only_sign = #{adminOnlySign,jdbcType=INTEGER},
</if>
<if test="authType != null">
auth_type = #{authType,jdbcType=INTEGER},
</if>
</set>
where menu_id = #{menuId,jdbcType=INTEGER}
</update>
......@@ -276,7 +286,8 @@
menu_type = #{menuType,jdbcType=INTEGER},
menu_version_name = #{menuVersionName,jdbcType=VARCHAR},
project_url_for_web = #{projectUrlForWeb,jdbcType=VARCHAR},
admin_only_sign = #{adminOnlySign,jdbcType=INTEGER}
admin_only_sign = #{adminOnlySign,jdbcType=INTEGER},
auth_type = #{authType,jdbcType=INTEGER}
where menu_id = #{menuId,jdbcType=INTEGER}
</update>
......
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