fix: 修复多租户岗位和角色管理customerId字段支持

- 前端修复:
  * 修复租户名称编辑功能,移除编辑时的禁用限制
  * 修复岗位管理中JavaScript大整数精度丢失问题,使用字符串格式传输ID
  * 优化岗位新增时的数据提交逻辑,确保customerId正确传递

- 后端修复:
  * 添加SysPositionAddDTO和SysPositionUpdateDTO中缺失的customerId字段
  * 添加SysRoleAddDTO和SysRoleUpdateDTO中缺失的customerId字段
  * 修复SysPositionMapper.xml和SysRoleMapper.xml中缺失的customer_id字段映射

- 数据库配置:
  * 统一数据库名称从lj-06改为ljwx,确保配置一致性

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
This commit is contained in:
2025-09-05 06:29:27 +08:00
co-authored by Claude
parent 3def7048b0
commit 79208eef91
12 changed files with 44 additions and 13 deletions
@@ -277,7 +277,7 @@ function beforeUpload(data: { file: UploadFileInfo; fileList: UploadFileInfo[] }
<NDrawerContent :title="title" :native-scrollbar="false" closable>
<NForm ref="formRef" :model="model">
<NFormItem :label="$t('page.customer.config.customerName')" path="customerName">
<NInput v-model:value="model.customerName" :placeholder="$t('page.customer.config.form.customerName')" :disabled="!isAdd" />
<NInput v-model:value="model.customerName" :placeholder="$t('page.customer.config.form.customerName')" />
</NFormItem>
<NFormItem :label="$t('page.customer.config.description')" path="description">
<NInput v-model:value="model.description" :placeholder="$t('page.customer.config.form.description')" />
@@ -37,8 +37,7 @@ const { columns, columnChecks, data, loading, getData, getDataByPage, mobilePagi
name: null,
status: null,
orgId: customerId,
// 非admin用户只查看自己租户的岗位
customerId: isAdmin.value ? null : customerId
customerId: customerId
},
columns: () => [
{
@@ -58,10 +58,10 @@ function createDefaultModel(): Model {
description: '',
sort: 1,
status: '1',
orgId: Number(props.customerId),
orgId: props.customerId,
weight: 1.0,
// 非admin用户创建的岗位自动关联到当前租户
customerId: props.isAdmin ? null : Number(props.customerId)
// 所有岗位都关联到当前租户
customerId: props.customerId
};
}
console.log('orgId', model.orgId);
@@ -89,8 +89,25 @@ function closeDrawer() {
async function handleSubmit() {
await validate();
// 新增时不发送id字段,编辑时需要id
const submitData = isEdit.value ? model : { ...model };
if (!isEdit.value) {
delete (submitData as any).id;
}
// 确保ID字段为字符串格式,避免精度丢失
if (submitData.orgId) {
submitData.orgId = String(submitData.orgId);
}
if (submitData.customerId) {
submitData.customerId = String(submitData.customerId);
}
console.log('提交数据:', JSON.stringify(submitData, null, 2));
const func = isEdit.value ? fetchUpdatePosition : fetchAddPosition;
const { error, data } = await func(model);
const { error, data } = await func(submitData);
if (!error && data) {
window.$message?.success(isEdit.value ? $t('common.updateSuccess') : $t('common.addSuccess'));
closeDrawer();
+1 -1
View File
@@ -13,7 +13,7 @@ MYSQL_HOST = os.getenv('MYSQL_HOST', 'ljwx-mysql') #统一使用ljwx-mysql
MYSQL_PORT = int(os.getenv('MYSQL_PORT', 3306))
MYSQL_USER = os.getenv('MYSQL_USER', 'root')
MYSQL_PASSWORD = os.getenv('MYSQL_PASSWORD', 'Ljwx2024!@#') #正确密码
MYSQL_DATABASE = os.getenv('MYSQL_DATABASE', 'lj-06') #正确数据库名
MYSQL_DATABASE = os.getenv('MYSQL_DATABASE', 'ljwx') #正确数据库名
# Redis configuration
REDIS_HOST = os.getenv('REDIS_HOST', 'ljwx-redis') #统一使用ljwx-redis
+1 -1
View File
@@ -13,7 +13,7 @@ MYSQL_HOST = os.getenv('MYSQL_HOST', 'mysql' if IS_DOCKER else '127.0.0.1')
MYSQL_PORT = int(os.getenv('MYSQL_PORT', 3306))
MYSQL_USER = os.getenv('MYSQL_USER', 'root')
MYSQL_PASSWORD = os.getenv('MYSQL_PASSWORD', '123456')
MYSQL_DATABASE = os.getenv('MYSQL_DATABASE', 'lj-06')
MYSQL_DATABASE = os.getenv('MYSQL_DATABASE', 'ljwx')
# Redis configuration
REDIS_HOST = os.getenv('REDIS_HOST', 'redis' if IS_DOCKER else '127.0.0.1')
@@ -1,7 +1,7 @@
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/${MYSQL_DATABASE:lj-06}?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai&useSSL=false&allowPublicKeyRetrieval=true&autoReconnect=true&failOverReadOnly=false&maxReconnects=3&initialTimeout=2&connectTimeout=60000&socketTimeout=60000
url: jdbc:mysql://localhost:3306/${MYSQL_DATABASE:ljwx}?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai&useSSL=false&allowPublicKeyRetrieval=true&autoReconnect=true&failOverReadOnly=false&maxReconnects=3&initialTimeout=2&connectTimeout=60000&socketTimeout=60000
username: ${MYSQL_USER:root}
password: ${MYSQL_PASSWORD:123456}
hikari: #本地开发连接池优化
@@ -150,7 +150,7 @@ ljwx:
# 为DruidConfiguration兼容性添加标准Spring Boot数据源配置
spring:
datasource:
url: jdbc:mysql://localhost:3306/${MYSQL_DATABASE:lj-06}?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai&useSSL=false&allowPublicKeyRetrieval=true&autoReconnect=true&failOverReadOnly=false&maxReconnects=3&initialTimeout=2&connectTimeout=60000&socketTimeout=60000
url: jdbc:mysql://localhost:3306/${MYSQL_DATABASE:ljwx}?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai&useSSL=false&allowPublicKeyRetrieval=true&autoReconnect=true&failOverReadOnly=false&maxReconnects=3&initialTimeout=2&connectTimeout=60000&socketTimeout=60000
username: ${MYSQL_USER:root}
password: ${MYSQL_PASSWORD:123456}
driver-class-name: com.mysql.cj.jdbc.Driver
@@ -48,4 +48,7 @@ public class SysPositionAddDTO implements Serializable {
@Schema(description = "权重")
private BigDecimal weight;
@Schema(description = "租户ID")
private Long customerId;
}
@@ -51,4 +51,7 @@ public class SysPositionUpdateDTO implements Serializable {
@Schema(description = "权重")
private BigDecimal weight;
@Schema(description = "租户ID")
private Long customerId;
}
@@ -40,4 +40,7 @@ public class SysRoleAddDTO implements Serializable {
@Schema(description = "是否为管理员角色(0:普通角色,1:管理员角色)")
private Integer isAdmin;
@Schema(description = "租户ID")
private Long customerId;
}
@@ -43,4 +43,7 @@ public class SysRoleUpdateDTO implements Serializable {
@Schema(description = "是否为管理员角色(0:普通角色,1:管理员角色)")
private Integer isAdmin;
@Schema(description = "租户ID")
private Long customerId;
}
@@ -39,6 +39,7 @@
<result column="update_user_id" property="updateUserId"/>
<result column="update_time" property="updateTime"/>
<result column="is_deleted" property="deleted"/>
<result column="customer_id" property="customerId"/>
</resultMap>
<!-- 通用查询结果列 -->
@@ -58,7 +59,8 @@
status,
weight,
is_deleted,
org_id
org_id,
customer_id
</sql>
</mapper>
@@ -19,6 +19,7 @@
<result column="update_user_id" property="updateUserId"/>
<result column="update_time" property="updateTime"/>
<result column="is_deleted" property="deleted"/>
<result column="customer_id" property="customerId"/>
</resultMap>
@@ -32,7 +33,7 @@
update_user_id,
update_time,
is_deleted,
parent_id, role_name, role_code, description, sort, status, is_admin
parent_id, role_name, role_code, description, sort, status, is_admin, customer_id
</sql>
<select id="queryRoleListWithUserId" resultType="com.ljwx.modules.system.domain.entity.SysRole">