Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Improvement-15744][parameter] project parameter add update time and update user id #15745

Merged
merged 14 commits into from
Apr 2, 2024
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ public Result updateProjectParameter(User loginUser, long projectCode, long code

projectParameter.setParamName(projectParameterName);
projectParameter.setParamValue(projectParameterValue);
projectParameter.setUpdateTime(new Date());
projectParameter.setOperator(loginUser.getId());

if (projectParameterMapper.updateById(projectParameter) > 0) {
log.info("Project parameter is updated and id is :{}", projectParameter.getId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ public void testUpdateProjectParameter() {
Mockito.when(projectParameterMapper.updateById(Mockito.any())).thenReturn(1);
result = projectParameterService.updateProjectParameter(loginUser, projectCode, 1, "key1", "value");
Assertions.assertEquals(Status.SUCCESS.getCode(), result.getCode());
ProjectParameter projectParameter = (ProjectParameter) result.getData();
Assertions.assertNotNull(projectParameter.getOperator());
Assertions.assertNotNull(projectParameter.getUpdateTime());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ public class ProjectParameter {
@TableField("user_id")
private Integer userId;

private Integer operator;

private long code;

@TableField("project_code")
Expand All @@ -56,4 +58,10 @@ public class ProjectParameter {
private Date createTime;

private Date updateTime;

@TableField(exist = false)
private String createUser;

@TableField(exist = false)
private String modifyUser;
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="org.apache.dolphinscheduler.dao.mapper.ProjectParameterMapper">
<sql id="baseSql">
id, param_name, param_value, code, project_code, user_id, create_time, update_time
id, param_name, param_value, code, project_code, user_id, operator, create_time, update_time
</sql>

<select id="queryByCode" resultType="org.apache.dolphinscheduler.dao.entity.ProjectParameter">
Expand Down Expand Up @@ -51,11 +51,15 @@

<select id="queryProjectParameterListPaging" resultType="org.apache.dolphinscheduler.dao.entity.ProjectParameter">
select
<include refid="baseSql"/>
from t_ds_project_parameter
pp.id, param_name, param_value, code, project_code, user_id, operator, pp.create_time, pp.update_time,
u.user_name as create_user,
u2.user_name as modify_user
from t_ds_project_parameter pp
left join t_ds_user u on pp.user_id = u.id
left join t_ds_user u2 on pp.operator = u2.id
where project_code = #{projectCode}
<if test="projectParameterIds != null and projectParameterIds.size() > 0">
and id in
and pp.id in
<foreach item="id" index="index" collection="projectParameterIds" open="(" separator="," close=")">
#{id}
</foreach>
Expand All @@ -65,7 +69,7 @@
OR param_value LIKE concat('%', #{searchName}, '%')
)
</if>
order by update_time desc
order by pp.update_time desc
</select>

<select id="queryByProjectCode" resultType="org.apache.dolphinscheduler.dao.entity.ProjectParameter">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,7 @@ CREATE TABLE t_ds_project_parameter
code bigint(20) NOT NULL,
project_code bigint(20) NOT NULL,
user_id int(11) DEFAULT NULL,
operator int(11) DEFAULT NULL,
create_time datetime NOT NULL,
update_time datetime DEFAULT NULL,
PRIMARY KEY (id),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,7 @@ CREATE TABLE `t_ds_project_parameter` (
`code` bigint(20) NOT NULL COMMENT 'encoding',
`project_code` bigint(20) NOT NULL COMMENT 'project code',
`user_id` int(11) DEFAULT NULL COMMENT 'creator id',
`operator` int(11) DEFAULT NULL COMMENT 'operator user id',
`create_time` datetime NOT NULL COMMENT 'create time',
`update_time` datetime DEFAULT NULL COMMENT 'update time',
PRIMARY KEY (`id`),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,7 @@ CREATE TABLE t_ds_project_parameter (
code bigint NOT NULL,
project_code bigint NOT NULL,
user_id int DEFAULT NULL ,
operator int DEFAULT NULL ,
create_time timestamp DEFAULT CURRENT_TIMESTAMP ,
update_time timestamp DEFAULT CURRENT_TIMESTAMP ,
PRIMARY KEY (id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ CREATE TABLE `t_ds_relation_project_worker_group` (
UNIQUE KEY unique_project_worker_group(project_code,worker_group)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE = utf8_bin;

ALTER TABLE t_ds_project_parameter ADD `operator` int(11) DEFAULT NULL COMMENT 'operator user id';
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,6 @@ CREATE TABLE t_ds_relation_project_worker_group (

DROP SEQUENCE IF EXISTS t_ds_relation_project_worker_group_sequence;
CREATE SEQUENCE t_ds_relation_project_worker_group_sequence;
ALTER TABLE t_ds_relation_project_worker_group ALTER COLUMN id SET DEFAULT NEXTVAL('t_ds_relation_project_worker_group_sequence');
ALTER TABLE t_ds_relation_project_worker_group ALTER COLUMN id SET DEFAULT NEXTVAL('t_ds_relation_project_worker_group_sequence');

ALTER TABLE t_ds_project_parameter ADD COLUMN IF NOT EXISTS operator int;
2 changes: 2 additions & 0 deletions dolphinscheduler-ui/src/locales/en_US/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -927,6 +927,8 @@ export default {
code: 'Parameter Code',
name: 'Parameter Name',
value: 'Parameter Value',
create_user: 'Create User',
modify_user: 'Modify User',
create_time: 'Create Time',
update_time: 'Update Time',
name_tips: 'Please enter your parameter name',
Expand Down
2 changes: 2 additions & 0 deletions dolphinscheduler-ui/src/locales/zh_CN/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -897,6 +897,8 @@ export default {
code: '参数编码',
name: '参数名称',
value: '参数值',
create_user: '创建用户',
modify_user: '修改用户',
create_time: '创建时间',
update_time: '更新时间',
name_tips: '请输入参数名称',
Expand Down
10 changes: 10 additions & 0 deletions dolphinscheduler-ui/src/views/projects/parameter/use-table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,16 @@ export function useTable() {
key: 'paramValue',
...COLUMN_WIDTH_CONFIG['name']
},
{
title: t('project.parameter.create_user'),
key: 'createUser',
...COLUMN_WIDTH_CONFIG['name']
},
{
title: t('project.parameter.modify_user'),
key: 'modifyUser',
...COLUMN_WIDTH_CONFIG['name']
},
{
title: t('project.parameter.create_time'),
key: 'createTime',
Expand Down
Loading