数据字典查询修改
This commit is contained in:
+79
@@ -21,6 +21,8 @@ import com.mhd.common.log.annotation.Log;
|
||||
import com.mhd.common.log.enums.BusinessType;
|
||||
import com.mhd.common.security.utils.SecurityUtils;
|
||||
import com.mhd.system.api.domain.SysDictData;
|
||||
import com.mhd.system.api.domain.SysDictType;
|
||||
import com.mhd.system.api.model.LoginUser;
|
||||
|
||||
/**
|
||||
* 数据字典信息
|
||||
@@ -41,10 +43,87 @@ public class SysDictDataController extends BaseController
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(SysDictData dictData)
|
||||
{
|
||||
if (!applyDictDataOrganizationFilterByDictType(dictData))
|
||||
{
|
||||
return getDataTable(new ArrayList<>());
|
||||
}
|
||||
startPage();
|
||||
List<SysDictData> list = dictDataService.selectDictList(dictData);
|
||||
return getDataTable(list);
|
||||
}
|
||||
/**
|
||||
* 列表组织过滤:按字典类型(sys_dict_type)上的组织维度过滤字典数据。
|
||||
* 前端可传 organizationId(通常来自所选字典类型行);南光组织(2827)可选组织或查全部,其他组织仅本组织。
|
||||
*
|
||||
* @return false 表示当前组织下无匹配字典类型,应返回空列表
|
||||
*/
|
||||
private boolean applyDictDataOrganizationFilterByDictType(SysDictData dictData)
|
||||
{
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (loginUser == null || loginUser.getUserPo() == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
Long loginUserOrganizationId = loginUser.getUserPo().getOrganizationId();
|
||||
Long loginUserTopOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
||||
Long frontendOrganizationId = dictData.getOrganizationId();
|
||||
|
||||
Long queryOrganizationId = null;
|
||||
Long queryTopOrganizationId = null;
|
||||
|
||||
if (loginUserOrganizationId != null && loginUserOrganizationId.equals(2827L))
|
||||
{
|
||||
if (frontendOrganizationId != null)
|
||||
{
|
||||
queryOrganizationId = frontendOrganizationId;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (frontendOrganizationId != null && !frontendOrganizationId.equals(loginUserOrganizationId))
|
||||
{
|
||||
queryOrganizationId = loginUserOrganizationId;
|
||||
}
|
||||
else if (frontendOrganizationId != null)
|
||||
{
|
||||
queryOrganizationId = frontendOrganizationId;
|
||||
}
|
||||
else
|
||||
{
|
||||
queryOrganizationId = loginUserOrganizationId;
|
||||
}
|
||||
queryTopOrganizationId = loginUserTopOrganizationId;
|
||||
}
|
||||
|
||||
if (StringUtils.isEmpty(dictData.getDictType()))
|
||||
{
|
||||
dictData.setOrganizationId(queryOrganizationId);
|
||||
dictData.setTopOrganizationId(queryTopOrganizationId);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (queryOrganizationId == null)
|
||||
{
|
||||
dictData.setOrganizationId(null);
|
||||
dictData.setTopOrganizationId(null);
|
||||
return true;
|
||||
}
|
||||
|
||||
SysDictType typeQuery = new SysDictType();
|
||||
typeQuery.setDictType(dictData.getDictType());
|
||||
typeQuery.setOrganizationId(queryOrganizationId);
|
||||
List<SysDictType> dictTypes = dictTypeService.selectDictTypeList(typeQuery);
|
||||
if (dictTypes.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
SysDictType dictTypeRow = dictTypes.get(0);
|
||||
dictData.setOrganizationId(dictTypeRow.getOrganizationId());
|
||||
dictData.setTopOrganizationId(dictTypeRow.getTopOrganizationId());
|
||||
return true;
|
||||
}
|
||||
|
||||
@PostMapping("/getDictDataList")
|
||||
public R<List<SysDictData>> getDictDataList(@RequestBody SysDictData sysDictData)
|
||||
{
|
||||
|
||||
+57
@@ -43,6 +43,7 @@ public class SysDictTypeController extends BaseController
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(SysDictType dictType)
|
||||
{
|
||||
applyDictTypeOrganizationFilter(dictType);
|
||||
startPage();
|
||||
List<SysDictType> list = dictTypeService.selectDictTypeList(dictType);
|
||||
return getDataTable(list);
|
||||
@@ -53,6 +54,7 @@ public class SysDictTypeController extends BaseController
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, SysDictType dictType)
|
||||
{
|
||||
applyDictTypeOrganizationFilter(dictType);
|
||||
List<SysDictType> list = dictTypeService.selectDictTypeList(dictType);
|
||||
ExcelUtil<SysDictType> util = new ExcelUtil<SysDictType>(SysDictType.class);
|
||||
util.exportExcel(response, list, "字典类型");
|
||||
@@ -85,6 +87,61 @@ public class SysDictTypeController extends BaseController
|
||||
return toAjax(dictTypeService.insertDictType(dict));
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表/导出组织过滤:优先使用前端传递的 organizationId;
|
||||
* 南光组织(2827)可按组织筛选或查全部,其他组织只能查本组织数据。
|
||||
*/
|
||||
private void applyDictTypeOrganizationFilter(SysDictType dictType)
|
||||
{
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (loginUser == null || loginUser.getUserPo() == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Long loginUserOrganizationId = loginUser.getUserPo().getOrganizationId();
|
||||
Long loginUserTopOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
||||
Long frontendOrganizationId = dictType.getOrganizationId();
|
||||
|
||||
if (loginUserOrganizationId != null && loginUserOrganizationId.equals(2827L))
|
||||
{
|
||||
if (frontendOrganizationId != null)
|
||||
{
|
||||
dictType.setOrganizationId(frontendOrganizationId);
|
||||
dictType.setTopOrganizationId(null);
|
||||
}
|
||||
else
|
||||
{
|
||||
dictType.setOrganizationId(null);
|
||||
dictType.setTopOrganizationId(null);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (frontendOrganizationId != null)
|
||||
{
|
||||
if (!frontendOrganizationId.equals(loginUserOrganizationId))
|
||||
{
|
||||
dictType.setOrganizationId(loginUserOrganizationId);
|
||||
}
|
||||
if (loginUserTopOrganizationId != null)
|
||||
{
|
||||
dictType.setTopOrganizationId(loginUserTopOrganizationId);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (loginUserOrganizationId != null)
|
||||
{
|
||||
dictType.setOrganizationId(loginUserOrganizationId);
|
||||
}
|
||||
if (loginUserTopOrganizationId != null)
|
||||
{
|
||||
dictType.setTopOrganizationId(loginUserTopOrganizationId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 写入组织维度:优先使用请求体中选择的组织;未传时使用当前登录用户所属组织;无登录上下文时按平台(0)处理。
|
||||
*/
|
||||
|
||||
@@ -34,12 +34,12 @@ public interface SysDictTypeMapper
|
||||
public SysDictType selectDictTypeById(Long dictId);
|
||||
|
||||
/**
|
||||
* 根据字典类型查询信息
|
||||
* 根据字典类型及组织查询信息(同一 dict_type 在不同组织下可重复)
|
||||
*
|
||||
* @param dictType 字典类型
|
||||
* @param dictType 字典类型(含 dictType、organizationId)
|
||||
* @return 字典类型
|
||||
*/
|
||||
public SysDictType selectDictTypeByType(String dictType);
|
||||
public SysDictType selectDictTypeByType(SysDictType dictType);
|
||||
|
||||
/**
|
||||
* 通过字典ID删除字典信息
|
||||
|
||||
+13
-1
@@ -441,7 +441,19 @@ public class SysDictDataServiceImpl extends ServiceImpl<SysDictDataMapper, SysDi
|
||||
{
|
||||
return;
|
||||
}
|
||||
SysDictType dictTypeRow = dictTypeService.selectDictTypeByType(dictType);
|
||||
Long organizationId = data.getOrganizationId();
|
||||
if (organizationId == null)
|
||||
{
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (loginUser != null && loginUser.getUserPo() != null)
|
||||
{
|
||||
organizationId = loginUser.getUserPo().getOrganizationId();
|
||||
}
|
||||
}
|
||||
SysDictType typeQuery = new SysDictType();
|
||||
typeQuery.setDictType(dictType);
|
||||
typeQuery.setOrganizationId(organizationId);
|
||||
SysDictType dictTypeRow = dictTypeService.selectDictTypeByType(typeQuery);
|
||||
if (dictTypeRow == null)
|
||||
{
|
||||
return;
|
||||
|
||||
+3
-3
@@ -113,13 +113,13 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据字典类型查询信息
|
||||
* 根据字典类型及组织查询信息
|
||||
*
|
||||
* @param dictType 字典类型
|
||||
* @param dictType 字典类型(含 dictType、organizationId)
|
||||
* @return 字典类型
|
||||
*/
|
||||
@Override
|
||||
public SysDictType selectDictTypeByType(String dictType)
|
||||
public SysDictType selectDictTypeByType(SysDictType dictType)
|
||||
{
|
||||
return dictTypeMapper.selectDictTypeByType(dictType);
|
||||
}
|
||||
|
||||
@@ -61,9 +61,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
where dict_id = #{dictId}
|
||||
</select>
|
||||
|
||||
<select id="selectDictTypeByType" parameterType="String" resultMap="SysDictTypeResult">
|
||||
<select id="selectDictTypeByType" parameterType="SysDictType" resultMap="SysDictTypeResult">
|
||||
<include refid="selectDictTypeVo"/>
|
||||
where dict_type = #{dictType}
|
||||
and IFNULL(organization_id, 0) = IFNULL(#{organizationId}, 0)
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<select id="checkDictTypeUnique" parameterType="SysDictType" resultMap="SysDictTypeResult">
|
||||
|
||||
Reference in New Issue
Block a user