修改system兼容性bug

This commit is contained in:
wanghao
2026-03-27 14:11:17 +08:00
parent 3005d8d80a
commit 5a870bb767
5 changed files with 32 additions and 9 deletions
@@ -1,6 +1,7 @@
package org.jeecg.modules.system.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
@@ -121,10 +122,11 @@ public class HealthConsultResource implements Serializable {
@Schema(title = "医院图片")
private String img;
/**
* 医院简介
* 医院简介DM8 保留字,需加引号)
*/
@Excel(name = "医院简介", width = 15)
@Schema(title = "医院简介")
@TableField(value = "\"DESC\"")
private String desc;
/**
* 排序序号
@@ -37,6 +37,15 @@ public interface SysDepartMapper extends BaseMapper<SysDepart> {
*/
public List<SysDepart> queryUserDeparts(@Param("userId") String userId);
/**
* 根据 orgCode 集合查询部门(仅返回 id、depart_name、org_code 三个字段),
* 用于替换 LambdaQueryWrapper.select() 避免 DM8 解析异常
*
* @param orgCodes 机构编码集合
* @return 部门列表
*/
List<SysDepart> selectByOrgCodes(@Param("orgCodes") List<String> orgCodes);
/**
* 根据部门编码集合查询部门id集合
* @param orgCodes
@@ -6,6 +6,17 @@
select * from QH_SYS_DEPART where id IN ( select dep_id from QH_SYS_USER_DEPART where user_id = #{userId} )
</select>
<!-- 根据 orgCode 集合查询部门(仅取 id/depart_name/org_code),用于 getMyDepartList,避免 LambdaQueryWrapper.select() 在 DM8 下的解析异常 -->
<select id="selectByOrgCodes" resultType="org.jeecg.modules.system.entity.SysDepart">
SELECT id, depart_name, org_code
FROM QH_SYS_DEPART
WHERE del_flag = '0'
AND org_code IN
<foreach item="orgCode" collection="orgCodes" open="(" separator="," close=")">
#{orgCode}
</foreach>
</select>
<!-- 根据username查询所拥有的部门 -->
<select id="queryDepartsByUsername" parameterType="String" resultType="org.jeecg.modules.system.entity.SysDepart">
SELECT *
@@ -1031,14 +1031,11 @@ public class SysDepartServiceImpl extends ServiceImpl<SysDepartMapper, SysDepart
list.add(companyOrgCode);
}
}
//字典code集合不为空
if (oConvertUtils.isNotEmpty(list)) {
//查询一级部门的数据
LambdaQueryWrapper<SysDepart> query = new LambdaQueryWrapper<>();
query.select(SysDepart::getDepartName, SysDepart::getId, SysDepart::getOrgCode);
query.eq(SysDepart::getDelFlag, String.valueOf(CommonConstant.DEL_FLAG_0));
query.in(SysDepart::getOrgCode, list);
return this.baseMapper.selectList(query);
//字典code集合不为空isNotEmpty 仅判 null,需额外判 size>0,避免空列表生成 IN () 导致 DM8 异常)
if (!list.isEmpty()) {
// 使用自定义 XML 查询替换 LambdaQueryWrapper.select()
// 避免 DM8 在解析带 select() 的 LambdaQueryWrapper 时出现语法异常
return this.baseMapper.selectByOrgCodes(list);
}
return null;
}
@@ -602,6 +602,10 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
@Override
@CacheEvict(value = {CacheConstant.SYS_USERS_CACHE}, key = "#userId")
public void updateUserDepart(String userId, String orgCode, Integer loginTenantId) {
// 两个更新字段均为 null 时跳过,避免生成 "UPDATE SET WHERE" 非法 SQL
if (orgCode == null && loginTenantId == null) {
return;
}
baseMapper.updateUserDepart(userId, orgCode, loginTenantId);
}