Skip to content

Commit

Permalink
[hotfix] Fix the problem that create_user and update_user are not dis…
Browse files Browse the repository at this point in the history
…played. (#252)
  • Loading branch information
zhangshenghang authored Jan 8, 2025
1 parent c09a158 commit d9383ab
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import org.apache.seatunnel.app.dal.entity.JobDefinition;
import org.apache.seatunnel.app.domain.response.PageInfo;
import org.apache.seatunnel.app.domain.response.job.JobDefinitionRes;

import lombok.NonNull;

Expand All @@ -32,7 +33,8 @@ public interface IJobDefinitionDao {

void updateJob(JobDefinition jobDefinition);

PageInfo<JobDefinition> getJob(String name, Integer pageNo, Integer pageSize, String jobMode);
PageInfo<JobDefinitionRes> getJob(
String name, Integer pageNo, Integer pageSize, String jobMode);

List<JobDefinition> getJobList(@NonNull String name);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.apache.seatunnel.app.dal.entity.JobDefinition;
import org.apache.seatunnel.app.dal.mapper.JobMapper;
import org.apache.seatunnel.app.domain.response.PageInfo;
import org.apache.seatunnel.app.domain.response.job.JobDefinitionRes;

import org.apache.commons.lang3.StringUtils;

Expand Down Expand Up @@ -56,9 +57,9 @@ public void updateJob(JobDefinition jobDefinition) {
}

@Override
public PageInfo<JobDefinition> getJob(
public PageInfo<JobDefinitionRes> getJob(
String searchName, Integer pageNo, Integer pageSize, String jobMode) {
IPage<JobDefinition> jobDefinitionIPage;
IPage<JobDefinitionRes> jobDefinitionIPage;
if (StringUtils.isEmpty(jobMode)) {
jobDefinitionIPage =
jobMapper.queryJobListPaging(new Page<>(pageNo, pageSize), searchName);
Expand All @@ -67,7 +68,7 @@ public PageInfo<JobDefinition> getJob(
jobMapper.queryJobListPagingWithJobMode(
new Page<>(pageNo, pageSize), searchName, jobMode);
}
PageInfo<JobDefinition> jobs = new PageInfo<>();
PageInfo<JobDefinitionRes> jobs = new PageInfo<>();
jobs.setData(jobDefinitionIPage.getRecords());
jobs.setPageSize(pageSize);
jobs.setPageNo(pageNo);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.apache.seatunnel.app.dal.mapper;

import org.apache.seatunnel.app.dal.entity.JobDefinition;
import org.apache.seatunnel.app.domain.response.job.JobDefinitionRes;

import org.apache.ibatis.annotations.Param;

Expand All @@ -28,10 +29,10 @@

public interface JobMapper extends BaseMapper<JobDefinition> {

IPage<JobDefinition> queryJobListPaging(
IPage<JobDefinitionRes> queryJobListPaging(
IPage<JobDefinition> page, @Param("searchName") String searchName);

IPage<JobDefinition> queryJobListPagingWithJobMode(
IPage<JobDefinitionRes> queryJobListPagingWithJobMode(
IPage<JobDefinition> page,
@Param("searchName") String searchName,
@Param("jobMode") String jobMode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,36 +119,7 @@ public PageInfo<JobDefinitionRes> getJob(
SeatunnelErrorEnum.ILLEGAL_STATE, "Unsupported JobMode");
}
}
PageInfo<JobDefinition> jobDefinitionPageInfo =
jobDefinitionDao.getJob(searchName, pageNo, pageSize, jobMode);
List<Integer> userIds =
jobDefinitionPageInfo.getData().stream()
.map(JobDefinition::getCreateUserId)
.collect(Collectors.toList());
userIds.addAll(
jobDefinitionPageInfo.getData().stream()
.map(JobDefinition::getUpdateUserId)
.collect(Collectors.toList()));
List<JobDefinitionRes> jobDefinitionResList = new ArrayList<>();
for (int i = 0; i < jobDefinitionPageInfo.getData().size(); i++) {
JobDefinition jobDefinition = jobDefinitionPageInfo.getData().get(i);
JobDefinitionRes jobDefinitionRes = new JobDefinitionRes();
jobDefinitionRes.setId(jobDefinition.getId());
jobDefinitionRes.setName(jobDefinition.getName());
jobDefinitionRes.setDescription(jobDefinition.getDescription());
jobDefinitionRes.setJobType(jobDefinition.getJobType());
jobDefinitionRes.setCreateUserId(jobDefinition.getCreateUserId());
jobDefinitionRes.setUpdateUserId(jobDefinitionRes.getUpdateUserId());
jobDefinitionRes.setCreateTime(jobDefinition.getCreateTime());
jobDefinitionRes.setUpdateTime(jobDefinition.getUpdateTime());
jobDefinitionResList.add(jobDefinitionRes);
}
PageInfo<JobDefinitionRes> pageInfo = new PageInfo<>();
pageInfo.setPageNo(jobDefinitionPageInfo.getPageNo());
pageInfo.setPageSize(jobDefinitionPageInfo.getPageSize());
pageInfo.setTotalCount(jobDefinitionPageInfo.getTotalCount());
pageInfo.setData(jobDefinitionResList);
return pageInfo;
return jobDefinitionDao.getJob(searchName, pageNo, pageSize, jobMode);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,37 +26,52 @@
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
</resultMap>
<sql id="Base_Column_List">
id
, `name`, `description`,`job_type`, create_user_id, update_user_id
id, `name`, `description`,`job_type`, create_user_id, update_user_id
</sql>
<sql id="Query_Job_Column_List">
t.id, t.`name`, t.`description`, t.`job_type`, t.create_user_id, t.update_user_id, t.create_time, t.update_time
</sql>
<insert id="insert" parameterType="org.apache.seatunnel.app.dal.entity.JobDefinition">
insert into `t_st_job_definition` (<include refid="Base_Column_List"/>)
values (#{id,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR},
#{description,jdbcType=VARCHAR},#{jobType,jdbcType=VARCHAR},
#{createUserId,jdbcType=BIGINT}, #{updateUserId,jdbcType=BIGINT})
</insert>
<select id="queryJobListPaging" resultType="org.apache.seatunnel.app.dal.entity.JobDefinition">
<select id="queryJobListPaging" resultType="org.apache.seatunnel.app.domain.response.job.JobDefinitionRes">
select
<include refid="Base_Column_List"/>, create_time, update_time
from t_st_job_definition
<include refid="Query_Job_Column_List"/> ,
cu.username as create_username,
uu.username as update_username
from
t_st_job_definition t
left join user cu on t.create_user_id = cu.id
left join user uu on t.update_user_id = uu.id
<where>
<if test="searchName!=null and searchName != ''">
and name LIKE concat('%', #{searchName}, '%')
</if>
<if test="searchName!=null and searchName!= ''">
and t.name LIKE concat('%', #{searchName}, '%')
</if>
</where>
order by update_time desc
order by
t.update_time desc
</select>

<select id="queryJobListPagingWithJobMode" resultType="org.apache.seatunnel.app.dal.entity.JobDefinition">
select t.*
from t_st_job_definition t
join (select * from t_st_job_version where job_mode = #{jobMode}) v on t.id = v.job_id
<select id="queryJobListPagingWithJobMode" resultType="org.apache.seatunnel.app.domain.response.job.JobDefinitionRes">
select
<include refid="Query_Job_Column_List"/> ,
cu.username as create_username,
uu.username as update_username
from
t_st_job_definition t
join (select * from t_st_job_version where job_mode = #{jobMode}) v on t.id = v.job_id
left join user cu on t.create_user_id = cu.id
left join user uu on t.update_user_id = uu.id
<where>
<if test="searchName!=null and searchName != ''">
and t.name LIKE concat('%', #{searchName}, '%')
</if>
<if test="searchName!=null and searchName != ''">
and t.name LIKE concat('%', #{searchName}, '%')
</if>
</where>
order by update_time desc
order by
update_time desc
</select>

<select id="queryJobList" resultType="org.apache.seatunnel.app.dal.entity.JobDefinition">
Expand Down

0 comments on commit d9383ab

Please sign in to comment.