Browse Source

数据权限功能提交

master
parent
commit
efc2ede885
  1. 13
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/DhcDataAuthController.java
  2. 53
      ruoyi-system/src/main/java/com/ruoyi/dhc/domain/DhcDataAuth.java
  3. 21
      ruoyi-system/src/main/java/com/ruoyi/dhc/mapper/DhcDataAuthMapper.java
  4. 13
      ruoyi-system/src/main/java/com/ruoyi/dhc/service/IDhcDataAuthService.java
  5. 37
      ruoyi-system/src/main/java/com/ruoyi/dhc/service/impl/DhcDataAuthServiceImpl.java
  6. 69
      ruoyi-system/src/main/resources/mapper/system/DhcDataAuthMapper.xml

13
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/DhcDataAuthController.java

@ -7,6 +7,7 @@ import javax.servlet.http.HttpServletResponse; @@ -7,6 +7,7 @@ import javax.servlet.http.HttpServletResponse;
import com.ruoyi.common.core.domain.entity.SysRole;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.dhc.domain.DhcDataAuth;
import com.ruoyi.dhc.domain.DhcDataAuthDetail;
import com.ruoyi.dhc.service.IDhcDataAuthService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
@ -46,7 +47,7 @@ public class DhcDataAuthController extends BaseController @@ -46,7 +47,7 @@ public class DhcDataAuthController extends BaseController
public TableDataInfo list(DhcDataAuth dhcDataAuth)
{
startPage();
List<DhcDataAuth> list = dhcDataAuthService.selectDhcDataAuthList(dhcDataAuth);
List<DhcDataAuth> list = dhcDataAuthService.selectDhcDataAuthByPage(dhcDataAuth);
return getDataTable(list);
}
@ -105,4 +106,14 @@ public class DhcDataAuthController extends BaseController @@ -105,4 +106,14 @@ public class DhcDataAuthController extends BaseController
{
return toAjax(dhcDataAuthService.deleteDhcDataAuthByDataAuthIds(dataAuthIds));
}
/**
* 批量删除数据权限
*/
@PreAuthorize("@ss.hasPermi('dhc:authData:remove')")
@Log(title = "数据权限", businessType = BusinessType.DELETE)
@PostMapping(value = "/removeBatch")
public AjaxResult removeBatch(@RequestBody List<DhcDataAuthDetail> detailList)
{
return toAjax(dhcDataAuthService.deleteDhcDataAuth(detailList));
}
}

53
ruoyi-system/src/main/java/com/ruoyi/dhc/domain/DhcDataAuth.java

@ -62,6 +62,59 @@ public class DhcDataAuth extends BaseEntity @@ -62,6 +62,59 @@ public class DhcDataAuth extends BaseEntity
private List<Long> dataAuthIds;
/** 用户账号 */
private String userName;
/** 用户昵称 */
private String nickName;
/** 手机号码 */
private String phonenumber;
private String areaCode;
private String areaName;
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getNickName() {
return nickName;
}
public void setNickName(String nickName) {
this.nickName = nickName;
}
public String getPhonenumber() {
return phonenumber;
}
public void setPhonenumber(String phonenumber) {
this.phonenumber = phonenumber;
}
public String getAreaCode() {
return areaCode;
}
public void setAreaCode(String areaCode) {
this.areaCode = areaCode;
}
public String getAreaName() {
return areaName;
}
public void setAreaName(String areaName) {
this.areaName = areaName;
}
public List<Long> getDataAuthIds() {
return dataAuthIds;
}

21
ruoyi-system/src/main/java/com/ruoyi/dhc/mapper/DhcDataAuthMapper.java

@ -84,4 +84,25 @@ public interface DhcDataAuthMapper @@ -84,4 +84,25 @@ public interface DhcDataAuthMapper
*/
public List<DhcDataAuthDetail> selectDhcDataAuthDetailList(DhcDataAuth dhcDataAuth);
/**
* 查询数据权限列表
*
* @param dhcDataAuth 数据权限
* @return 数据权限集合
*/
public List<DhcDataAuth> selectDhcDataAuthByPage(DhcDataAuth dhcDataAuth);
/**
* 删除数据权限明细
*
* @param detail 数据权限明细列表
* @return 结果
*/
public int deleteDataAuthDetail(DhcDataAuthDetail detail);
/**
* 查询数据权限明细
*
* @param detail 数据权限明细列表
* @return 结果
*/
public int selectDataAuthDetailCount(DhcDataAuthDetail detail);
}

13
ruoyi-system/src/main/java/com/ruoyi/dhc/service/IDhcDataAuthService.java

@ -2,6 +2,7 @@ package com.ruoyi.dhc.service; @@ -2,6 +2,7 @@ package com.ruoyi.dhc.service;
import java.util.List;
import com.ruoyi.dhc.domain.DhcDataAuth;
import com.ruoyi.dhc.domain.DhcDataAuthDetail;
/**
* 数据权限Service接口
@ -54,8 +55,16 @@ public interface IDhcDataAuthService @@ -54,8 +55,16 @@ public interface IDhcDataAuthService
/**
* 删除数据权限信息
*
* @param dataAuthId 数据权限主键
* @param detailList
* @return 结果
*/
public int deleteDhcDataAuthByDataAuthId(Long dataAuthId);
public int deleteDhcDataAuth(List<DhcDataAuthDetail> detailList);
/**
* 查询数据权限列表
*
* @param dhcDataAuth 数据权限
* @return 数据权限集合
*/
public List<DhcDataAuth> selectDhcDataAuthByPage(DhcDataAuth dhcDataAuth);
}

37
ruoyi-system/src/main/java/com/ruoyi/dhc/service/impl/DhcDataAuthServiceImpl.java

@ -115,15 +115,40 @@ public class DhcDataAuthServiceImpl implements IDhcDataAuthService @@ -115,15 +115,40 @@ public class DhcDataAuthServiceImpl implements IDhcDataAuthService
/**
* 删除数据权限信息
*
* @param dataAuthId 数据权限主键
* @param detailList
* @return 结果
*/
@Override
public int deleteDhcDataAuthByDataAuthId(Long dataAuthId)
public int deleteDhcDataAuth(List<DhcDataAuthDetail> detailList)
{
DhcDataAuth dhcDataAuth = new DhcDataAuth();
dhcDataAuth.setDataAuthId(dataAuthId);
dhcDataAuthMapper.deleteDataAuthDetailByDataAuthIds(dhcDataAuth);
return dhcDataAuthMapper.deleteDhcDataAuthByDataAuthId(dataAuthId);
for (DhcDataAuthDetail detail : detailList) {
detail.setDetailType("0");
dhcDataAuthMapper.deleteDataAuthDetail(detail);
Integer count = dhcDataAuthMapper.selectDataAuthDetailCount(detail);
if (count == 0) {
dhcDataAuthMapper.deleteDhcDataAuthByDataAuthId(detail.getDataAuthId());
}
}
return 1;
}
/**
* 查询数据权限列表
*
* @param dhcDataAuth 数据权限
* @return 数据权限
*/
@Override
public List<DhcDataAuth> selectDhcDataAuthByPage(DhcDataAuth dhcDataAuth)
{ List<DhcDataAuth> list = dhcDataAuthMapper.selectDhcDataAuthByPage(dhcDataAuth);
list.forEach(item->{
String[] array = item.getDeptAllId().split("/");
List<Long> deptIds = new ArrayList<>();
for (String deptId : array) {
deptIds.add(Long.valueOf(deptId));
}
item.setDeptIds(deptIds);
});
return list;
}
}

69
ruoyi-system/src/main/resources/mapper/system/DhcDataAuthMapper.xml

@ -21,6 +21,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" @@ -21,6 +21,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="detailCode" column="detail_code" />
<result property="detailName" column="detail_name" />
</resultMap>
<resultMap type="DhcDataAuth" id="DhcDataAuthResults">
<result property="dataAuthId" column="data_auth_id" />
<result property="userId" column="user_id" />
<result property="deptId" column="dept_id" />
<result property="authNode" column="auth_node" />
<result property="productLineCode" column="product_line_code" />
<result property="areaType" column="area_type" />
<result property="deptAllId" column="dept_all_id" />
<result property="deptAllName" column="dept_all_Name"/>
<result property="userName" column="user_name" />
<result property="nickName" column="nick_name" />
<result property="phonenumber" column="phonenumber" />
<result property="areaCode" column="areaCode" />
<result property="areaName" column="areaName" />
</resultMap>
<sql id="selectDhcDataAuthVo">
select data_auth_id, user_id, dept_id, auth_node, product_line_code, area_type,b.dept_all_id,dept_all_Name from dhc_data_auth
@ -93,12 +108,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" @@ -93,12 +108,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<where>
<if test="dataAuthId != null "> and data_auth_id = #{dataAuthId}</if>
<if test="detailType != null and detailType != ''"> and detail_type = #{detailType}</if>
<if test="detailList != null and detailList.size() &gt; 0">
and detail_code in
<foreach item="detailCode" collection="detailList" open="(" separator="," close=")">
#{detailCode}
</foreach>
</if>
<if test="dataAuthIds != null and dataAuthIds.size() &gt; 0">
and data_auth_id in
<foreach item="dataAuthId" collection="dataAuthIds" open="(" separator="," close=")">
@ -116,4 +125,52 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" @@ -116,4 +125,52 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectDhcDataAuthDetailList" parameterType="DhcDataAuth" resultMap="DhcDataAuthDetailResult">
select detail_code,detail_name from dhc_data_auth_detail where data_auth_id = #{dataAuthId} and detail_type = #{detailType}
</select>
<select id="selectDhcDataAuthByPage" parameterType="DhcDataAuth" resultMap="DhcDataAuthResults">
SELECT
a.data_auth_id,
a.user_id,
a.dept_id,
a.auth_node,
a.product_line_code,
a.area_type,
a.dept_all_id,
a.dept_all_Name,
b.user_name,
b.nick_name,
b.phonenumber,
c.detail_code AS areaCode,
c.detail_name AS AreaName
FROM
dhc_data_auth a
JOIN sys_user b ON a.user_id = b.user_id
JOIN dhc_data_auth_detail c ON c.data_auth_id = c.data_auth_id
<where>
<if test="userId != null "> and a.user_id = #{userId}</if>
<if test="deptId != null "> and a.dept_id = #{deptId}</if>
<if test="authNode != null and authNode != ''"> and a.auth_node = #{authNode}</if>
<if test="productLineCode != null and productLineCode != ''"> and a.product_line_code = #{productLineCode}</if>
<if test="areaType != null and areaType != ''"> and a.area_type = #{areaType}</if>
<if test="userName != null and userName != ''">
AND b.user_name like concat('%', #{userName}, '%')
</if>
<if test="nickName != null and nickName != ''">
AND b.nick_name like concat('%', #{nickName}, '%')
</if>
<if test="phonenumber != null and phonenumber != ''">
AND b.phonenumber like concat('%', #{phonenumber}, '%')
</if>
<if test="detailCodes != null and detailCodes.size() &gt; 0">
and c.detail_code in
<foreach item="detailCode" collection="detailCodes" open="(" separator="," close=")">
#{detailCode}
</foreach>
</if>
</where>
</select>
<delete id="deleteDataAuthDetail" parameterType="DhcDataAuthDetail">
delete from dhc_data_auth_detail where data_auth_id = #{dataAuthId} and detail_code = #{detailCode} and detail_type = #{detailType}
</delete>
<select id="selectDataAuthDetailCount" parameterType="DhcDataAuthDetail" resultType="integer">
select count(1) from dhc_data_auth_detail where data_auth_id = #{dataAuthId} and detail_type = #{detailType}
</select>
</mapper>
Loading…
Cancel
Save