feat(biz_project): 加 create_user_id 列, JOIN biz_person 取创建人姓名

This commit is contained in:
郭庆泰
2026-08-18 23:00:41 +08:00
parent ac31387b95
commit ffda9c618e
5 changed files with 45 additions and 7 deletions
+12
View File
@@ -36,6 +36,18 @@
| CSS 不是原型风格 (Element Plus 默认) | 完整照搬原型 CSS: #169bd5 主按钮 + 32px input + 12px 灰字面包屑 + 22px h1 + ff4d4f 红字 + grid 1fr 1fr + 768px 响应式 | | CSS 不是原型风格 (Element Plus 默认) | 完整照搬原型 CSS: #169bd5 主按钮 + 32px input + 12px 灰字面包屑 + 22px h1 + ff4d4f 红字 + grid 1fr 1fr + 768px 响应式 |
| 字段映射 | 项目编号→projectNo, 项目名称→projectName, 总场次/总期数→totalSessions (不是 totalPeriods, biz_project 没此字段), 支持单位→sponsorOrgName (JOIN biz_org), 创建时间→createTime, 创建人员→createBy, 会议名称默认=项目名称 | | 字段映射 | 项目编号→projectNo, 项目名称→projectName, 总场次/总期数→totalSessions (不是 totalPeriods, biz_project 没此字段), 支持单位→sponsorOrgName (JOIN biz_org), 创建时间→createTime, 创建人员→createBy, 会议名称默认=项目名称 |
### 第三轮: biz_project 加 create_user_id 列 (commit `待push`)
| 问题 | 修复 |
|---|---|
| `biz_project` 没存"创建人 user_id", 只存 `create_by varchar(64)` (兼容字段, 来自 BaseEntity MetaObjectHandler 自动填当前登录用户名), 新建会议页 `snap.createBy` 显示原始用户名而非真实姓名 | DB: `ALTER TABLE biz_project ADD COLUMN create_user_id bigint DEFAULT NULL COMMENT '创建人user_id (JOIN biz_person 取 name)' AFTER create_by;` |
| BizProject 实体无 `createUserId` / `createUserName` 字段 | `BizProject.java:80-83` 加 2 字段 + getter/setter; createUserName 不入库 (派生) |
| BizProjectMapper.xml 不查 `create_user_id` | `BizProjectMapper.xml:4-42 resultMap` 加 2 result; `selectFields` (主) + `selectFieldsForSponsor` + `selectExecutorList` 全部加 `p.create_user_id` 列 + `LEFT JOIN biz_person bp ON bp.user_id = p.create_user_id``bp.name as create_user_name`; INSERT/UPDATE 加 `create_user_id` (INSERT 由 service 自动写, 旧调用方兼容) |
| BizProjectServiceImpl.insert 不写 create_user_id | `BizProjectServiceImpl:32-37``entity.setCreateUserId(SecurityUtils.getUserId())` (留 null 给手工 import/seed 入口) |
| MeetingNew.vue 用 `snap.createBy` | 改 `snap.createUserName`; onMounted 兼容 `d.createUserName \|\| d.createBy \|\| ''` |
| 旧数据 (11 行) create_user_id 全 NULL, project 13 是 seed (create_time=NULL, lead_user_id=101) | **不回填** (用户指示: 测试数据, 无修改价值); 后续新项目 INSERT 自动带 user_id |
| 受影响角色 (免费) | sponsor/executor 端 `Projects.vue` 列表的"创建人"列 (如有) 也走新字段 — 暂未引用, 不破坏 |
--- ---
## 0. 4 跳定位 (铁律: 不按名字猜) ## 0. 4 跳定位 (铁律: 不按名字猜)
@@ -80,6 +80,10 @@ public class BizProject extends BaseEntity {
/** create_by */ /** create_by */
@Excel(name = "create_by") @Excel(name = "create_by")
private String createBy; private String createBy;
/** create_user_id (创建人 sys_user.user_id, JOIN biz_person 取 name) */
private Long createUserId;
/** create_user_name (LEFT JOIN biz_person.name 派生, 不入库, 仅展示) */
private String createUserName;
/** create_time */ /** create_time */
@Excel(name = "create_time") @Excel(name = "create_time")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@@ -183,6 +187,10 @@ public class BizProject extends BaseEntity {
public void setIsBidProject(String isBidProject) { this.isBidProject = isBidProject; } public void setIsBidProject(String isBidProject) { this.isBidProject = isBidProject; }
public String getCreateBy() { return createBy; } public String getCreateBy() { return createBy; }
public void setCreateBy(String createBy) { this.createBy = createBy; } public void setCreateBy(String createBy) { this.createBy = createBy; }
public Long getCreateUserId() { return createUserId; }
public void setCreateUserId(Long createUserId) { this.createUserId = createUserId; }
public String getCreateUserName() { return createUserName; }
public void setCreateUserName(String createUserName) { this.createUserName = createUserName; }
public Date getCreateTime() { return createTime; } public Date getCreateTime() { return createTime; }
public void setCreateTime(Date createTime) { this.createTime = createTime; } public void setCreateTime(Date createTime) { this.createTime = createTime; }
public String getUpdateBy() { return updateBy; } public String getUpdateBy() { return updateBy; }
@@ -6,6 +6,7 @@ import org.springframework.stereotype.Service;
import com.ruoyi.business.domain.BizProject; import com.ruoyi.business.domain.BizProject;
import com.ruoyi.business.mapper.BizProjectMapper; import com.ruoyi.business.mapper.BizProjectMapper;
import com.ruoyi.business.service.IBizProjectService; import com.ruoyi.business.service.IBizProjectService;
import com.ruoyi.common.utils.SecurityUtils;
@Service @Service
public class BizProjectServiceImpl implements IBizProjectService public class BizProjectServiceImpl implements IBizProjectService
@@ -28,7 +29,13 @@ public class BizProjectServiceImpl implements IBizProjectService
@Override @Override
// 注: biz_project.project_id 用 DB AUTO_INCREMENT, 不需要 SnowflakeId 注入; // 注: biz_project.project_id 用 DB AUTO_INCREMENT, 不需要 SnowflakeId 注入;
// 项目 ID 用 Long 后, SnowflakeId.injectIfEmpty 反射 setProjectId(String) 会 NoSuchMethodException 被吞掉 (SnowflakeId.java:30-31), 行为安全. // 项目 ID 用 Long 后, SnowflakeId.injectIfEmpty 反射 setProjectId(String) 会 NoSuchMethodException 被吞掉 (SnowflakeId.java:30-31), 行为安全.
public int insert(BizProject entity) { return bizProjectMapper.insert(entity); } // create_user_id 走当前登录用户 (前台 API 无 @DataScope, 不会被过滤; 后台 @PreAuthorize 受角色限制)
public int insert(BizProject entity) {
if (entity.getCreateUserId() == null) {
entity.setCreateUserId(SecurityUtils.getUserId());
}
return bizProjectMapper.insert(entity);
}
@Override @Override
public int updateByPrimaryKey(BizProject entity) public int updateByPrimaryKey(BizProject entity)
{ return bizProjectMapper.updateByPrimaryKey(entity); } { return bizProjectMapper.updateByPrimaryKey(entity); }
@@ -27,6 +27,8 @@
<result property="isFinished" column="is_finished" /> <result property="isFinished" column="is_finished" />
<result property="isSettled" column="is_settled" /> <result property="isSettled" column="is_settled" />
<result property="createBy" column="create_by" /> <result property="createBy" column="create_by" />
<result property="createUserId" column="create_user_id" />
<result property="createUserName" column="create_user_name" />
<result property="createTime" column="create_time" /> <result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" /> <result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" /> <result property="updateTime" column="update_time" />
@@ -41,9 +43,10 @@
<result property="publishUrl" column="publish_url" /> <result property="publishUrl" column="publish_url" />
</resultMap> </resultMap>
<sql id="selectFields"> <sql id="selectFields">
select p.project_id, p.project_no, p.project_name, p.total_sessions, p.done_sessions, p.todo_sessions, p.total_amount, p.available_amount, p.paid_labor_amount, p.paid_meeting_amount, p.manager_score, p.sponsor_score, p.sponsor_admin_user_name, p.project_form, p.is_finished, p.is_settled, p.sponsor_admin_user_id, p.lead_user_id, p.is_bid_project, p.create_by, p.create_time, p.update_by, p.update_time, p.manage_fee, p.start_time, p.end_time, p.submit_deadline_days, p.support_contract_url, p.execute_contract_url, p.invitation_url, p.support_letter_url, p.publish_url, select p.project_id, p.project_no, p.project_name, p.total_sessions, p.done_sessions, p.todo_sessions, p.total_amount, p.available_amount, p.paid_labor_amount, p.paid_meeting_amount, p.manager_score, p.sponsor_score, p.sponsor_admin_user_name, p.project_form, p.is_finished, p.is_settled, p.sponsor_admin_user_id, p.lead_user_id, p.is_bid_project, p.create_by, p.create_user_id, p.create_time, p.update_by, p.update_time, p.manage_fee, p.start_time, p.end_time, p.submit_deadline_days, p.support_contract_url, p.execute_contract_url, p.invitation_url, p.support_letter_url, p.publish_url,
o.org_name as sponsor_org_name, o.org_name as sponsor_org_name,
lu.user_name as lead_user_name, lu.user_name as lead_user_name,
bp.name as create_user_name,
(select group_concat(distinct o2.org_name separator ',') (select group_concat(distinct o2.org_name separator ',')
from biz_project_assign bpa from biz_project_assign bpa
join biz_org o2 on o2.org_id = bpa.execution_unit_id and o2.org_type = 'executor' join biz_org o2 on o2.org_id = bpa.execution_unit_id and o2.org_type = 'executor'
@@ -51,6 +54,7 @@
from biz_project p from biz_project p
left join biz_org o on o.user_id = p.sponsor_admin_user_id and o.org_type = 'sponsor' left join biz_org o on o.user_id = p.sponsor_admin_user_id and o.org_type = 'sponsor'
left join sys_user lu on lu.user_id = p.lead_user_id left join sys_user lu on lu.user_id = p.lead_user_id
left join biz_person bp on bp.user_id = p.create_user_id
</sql> </sql>
<!-- sponsor 端专属查询: 与 selectFields 等价 (sponsor 评分改走 biz_project_rating 子表, 这里只查项目本体) --> <!-- sponsor 端专属查询: 与 selectFields 等价 (sponsor 评分改走 biz_project_rating 子表, 这里只查项目本体) -->
@@ -59,12 +63,13 @@
p.total_amount, p.available_amount, p.paid_labor_amount, p.paid_meeting_amount, p.total_amount, p.available_amount, p.paid_labor_amount, p.paid_meeting_amount,
p.manager_score, p.sponsor_score, p.sponsor_admin_user_name, p.project_form, p.is_finished, p.is_settled, p.manager_score, p.sponsor_score, p.sponsor_admin_user_name, p.project_form, p.is_finished, p.is_settled,
p.sponsor_admin_user_id, p.lead_user_id, p.is_bid_project, p.sponsor_admin_user_id, p.lead_user_id, p.is_bid_project,
p.create_by, p.create_time, p.update_by, p.update_time, p.manage_fee, p.create_by, p.create_user_id, p.create_time, p.update_by, p.update_time, p.manage_fee,
p.start_time, p.end_time, p.submit_deadline_days, p.start_time, p.end_time, p.submit_deadline_days,
p.support_contract_url, p.execute_contract_url, p.invitation_url, p.support_letter_url, p.support_contract_url, p.execute_contract_url, p.invitation_url, p.support_letter_url,
p.publish_url, p.publish_url,
o.org_name as sponsor_org_name, o.org_name as sponsor_org_name,
lu.user_name as lead_user_name, lu.user_name as lead_user_name,
bp.name as create_user_name,
(select group_concat(distinct o2.org_name separator ',') (select group_concat(distinct o2.org_name separator ',')
from biz_project_assign bpa from biz_project_assign bpa
join biz_org o2 on o2.org_id = bpa.execution_unit_id and o2.org_type = 'executor' join biz_org o2 on o2.org_id = bpa.execution_unit_id and o2.org_type = 'executor'
@@ -72,6 +77,7 @@
from biz_project p from biz_project p
left join biz_org o on o.user_id = p.sponsor_admin_user_id and o.org_type = 'sponsor' left join biz_org o on o.user_id = p.sponsor_admin_user_id and o.org_type = 'sponsor'
left join sys_user lu on lu.user_id = p.lead_user_id left join sys_user lu on lu.user_id = p.lead_user_id
left join biz_person bp on bp.user_id = p.create_user_id
</sql> </sql>
<select id="selectByPrimaryKey" resultMap="BizProjectResult" parameterType="Long"> <select id="selectByPrimaryKey" resultMap="BizProjectResult" parameterType="Long">
<include refid="selectFields"/> <include refid="selectFields"/>
@@ -105,9 +111,10 @@
注: executor 角色无评分/聚合分需求, 复用 selectFields (含 sponsor_score / manager_score) 注: executor 角色无评分/聚合分需求, 复用 selectFields (含 sponsor_score / manager_score)
--> -->
<select id="selectExecutorList" resultMap="BizProjectResult" parameterType="BizProject"> <select id="selectExecutorList" resultMap="BizProjectResult" parameterType="BizProject">
select distinct p.project_id, p.project_no, p.project_name, p.total_sessions, p.done_sessions, p.todo_sessions, p.total_amount, p.available_amount, p.paid_labor_amount, p.paid_meeting_amount, p.manager_score, p.sponsor_score, p.sponsor_admin_user_name, p.project_form, p.is_finished, p.is_settled, p.sponsor_admin_user_id, p.lead_user_id, p.is_bid_project, p.create_by, p.create_time, p.update_by, p.update_time, p.manage_fee, p.start_time, p.end_time, p.submit_deadline_days, p.support_contract_url, p.execute_contract_url, p.invitation_url, p.support_letter_url, p.publish_url, select distinct p.project_id, p.project_no, p.project_name, p.total_sessions, p.done_sessions, p.todo_sessions, p.total_amount, p.available_amount, p.paid_labor_amount, p.paid_meeting_amount, p.manager_score, p.sponsor_score, p.sponsor_admin_user_name, p.project_form, p.is_finished, p.is_settled, p.sponsor_admin_user_id, p.lead_user_id, p.is_bid_project, p.create_by, p.create_user_id, p.create_time, p.update_by, p.update_time, p.manage_fee, p.start_time, p.end_time, p.submit_deadline_days, p.support_contract_url, p.execute_contract_url, p.invitation_url, p.support_letter_url, p.publish_url,
o.org_name as sponsor_org_name, o.org_name as sponsor_org_name,
lu.user_name as lead_user_name, lu.user_name as lead_user_name,
bp.name as create_user_name,
(select group_concat(distinct o2.org_name separator ',') (select group_concat(distinct o2.org_name separator ',')
from biz_project_assign bpa2 from biz_project_assign bpa2
join biz_org o2 on o2.org_id = bpa2.execution_unit_id and o2.org_type = 'executor' join biz_org o2 on o2.org_id = bpa2.execution_unit_id and o2.org_type = 'executor'
@@ -126,6 +133,7 @@
join biz_project_assign a on a.project_id = p.project_id join biz_project_assign a on a.project_id = p.project_id
left join biz_org o on o.user_id = p.sponsor_admin_user_id and o.org_type = 'sponsor' left join biz_org o on o.user_id = p.sponsor_admin_user_id and o.org_type = 'sponsor'
left join sys_user lu on lu.user_id = p.lead_user_id left join sys_user lu on lu.user_id = p.lead_user_id
left join biz_person bp on bp.user_id = p.create_user_id
<where> <where>
(a.exec_user_id = #{params.executorUserId} (a.exec_user_id = #{params.executorUserId}
or a.execution_unit_id = (select org_id from biz_org where user_id = #{params.executorUserId} and org_type = 'executor')) or a.execution_unit_id = (select org_id from biz_org where user_id = #{params.executorUserId} and org_type = 'executor'))
@@ -204,6 +212,7 @@
<if test="leadUserId != null">lead_user_id,</if> <if test="leadUserId != null">lead_user_id,</if>
<if test="isBidProject != null and isBidProject != ''">is_bid_project,</if> <if test="isBidProject != null and isBidProject != ''">is_bid_project,</if>
<if test="createBy != null">create_by,</if> <if test="createBy != null">create_by,</if>
<if test="createUserId != null">create_user_id,</if>
<if test="createTime != null">create_time,</if> <if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if> <if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if> <if test="updateTime != null">update_time,</if>
@@ -238,6 +247,7 @@
<if test="leadUserId != null">#{leadUserId},</if> <if test="leadUserId != null">#{leadUserId},</if>
<if test="isBidProject != null and isBidProject != ''">#{isBidProject},</if> <if test="isBidProject != null and isBidProject != ''">#{isBidProject},</if>
<if test="createBy != null">#{createBy},</if> <if test="createBy != null">#{createBy},</if>
<if test="createUserId != null">#{createUserId},</if>
<if test="createTime != null">#{createTime},</if> <if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if> <if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if> <if test="updateTime != null">#{updateTime},</if>
@@ -283,6 +293,7 @@
<if test="leadUserId != null">lead_user_id = #{leadUserId},</if> <if test="leadUserId != null">lead_user_id = #{leadUserId},</if>
<if test="isBidProject != null and isBidProject != ''">is_bid_project = #{isBidProject},</if> <if test="isBidProject != null and isBidProject != ''">is_bid_project = #{isBidProject},</if>
<if test="createBy != null">create_by = #{createBy},</if> <if test="createBy != null">create_by = #{createBy},</if>
<if test="createUserId != null">create_user_id = #{createUserId},</if>
<if test="createTime != null">create_time = #{createTime},</if> <if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if> <if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if> <if test="updateTime != null">update_time = #{updateTime},</if>
+3 -3
View File
@@ -24,7 +24,7 @@
<span class="form-value">{{ snap.createTime }}</span> <span class="form-value">{{ snap.createTime }}</span>
</el-form-item> </el-form-item>
<el-form-item label="创建人员"> <el-form-item label="创建人员">
<span class="form-value">{{ snap.createBy }}</span> <span class="form-value">{{ snap.createUserName }}</span>
</el-form-item> </el-form-item>
<!-- 右列 5 : 1 只读 + 4 输入 --> <!-- 右列 5 : 1 只读 + 4 输入 -->
@@ -72,7 +72,7 @@ const snap = reactive({
totalSessions: '', totalSessions: '',
sponsorOrgName: '', sponsorOrgName: '',
createTime: '', createTime: '',
createBy: '' createUserName: ''
}) })
// 表单 (右列 5 项: meetingName 只读 + 4 输入) // 表单 (右列 5 项: meetingName 只读 + 4 输入)
@@ -126,7 +126,7 @@ onMounted(async () => {
snap.totalSessions = d.totalSessions ?? '' snap.totalSessions = d.totalSessions ?? ''
snap.sponsorOrgName = d.sponsorOrgName || '' snap.sponsorOrgName = d.sponsorOrgName || ''
snap.createTime = d.createTime || '' snap.createTime = d.createTime || ''
snap.createBy = d.createBy || '' snap.createUserName = d.createUserName || d.createBy || ''
// 会议名称默认 = 项目名称 (跟红字提示一致) // 会议名称默认 = 项目名称 (跟红字提示一致)
form.projectNo = d.projectNo || '' form.projectNo = d.projectNo || ''
form.projectName = d.projectName || '' form.projectName = d.projectName || ''