Skip to content

Commit

Permalink
Merge pull request #40 from fqliao/feature-milestone2
Browse files Browse the repository at this point in the history
add list project info for admin
  • Loading branch information
fqliao authored Sep 5, 2024
2 parents 80486cc + 9971397 commit 34fbc9e
Show file tree
Hide file tree
Showing 37 changed files with 437 additions and 68 deletions.
8 changes: 6 additions & 2 deletions db/wedpr_ddl.sql
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,15 @@ create table if not exists `wedpr_project_table`(
`owner_agency` varchar(255) not null comment "项目所属机构",
`project_type` varchar(255) not null comment "项目类型(Export/Wizard)",
`label` varchar(1024) comment "项目标签",
`report_status` tinyint default 0 comment "上报状态",
`create_time` DATETIME DEFAULT CURRENT_TIMESTAMP comment "项目创建时间",
`last_update_time` DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP comment "项目更新时间",
primary key (`id`),
unique index name_index(`name`(128)),
index owner_index(`owner`(128), `owner_agency`(128)),
index project_type_index(`project_type`(128)),
index label_index(`label`(128))
index label_index(`label`(128)),
index report_status_index(`report_status`)
)ENGINE=InnoDB default charset=utf8mb4 default collate=utf8mb4_bin ROW_FORMAT=DYNAMIC;

-- the job table
Expand All @@ -124,14 +126,16 @@ create table if not exists `wedpr_job_table`(
`param` longtext comment "任务参数(json)",
`status` varchar(255) comment "任务状态",
`job_result` longtext comment "任务执行结果(json)",
`report_status` tinyint default 0 comment "上报状态",
`create_time` DATETIME DEFAULT CURRENT_TIMESTAMP comment "任务创建时间",
`last_update_time` DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP comment "任务更新时间",
primary key(`id`),
index name_index(`name`(128)),
index owner_index(`owner`(128)),
index owner_agency_index(`owner_agency`(128)),
index project_index(`project_name`(128)),
index status_index(`status`(128))
index status_index(`status`(128)),
index report_status_index(`report_status`)
)ENGINE=InnoDB default charset=utf8mb4 default collate=utf8mb4_bin ROW_FORMAT=DYNAMIC;

-- job dataset relationship table
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
@EqualsAndHashCode(callSuper = true)
@Data
@ToString
@EqualsAndHashCode(callSuper = false)
public class CredentialRequest extends PageRequest {
private ApiCredentialDO condition = new ApiCredentialDO(true);
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
@EqualsAndHashCode(callSuper = true)
@Data
@ToString
@EqualsAndHashCode(callSuper = false)
public class JupyterRequest extends PageRequest {
private JupyterInfoDO condition = new JupyterInfoDO(true);
}
9 changes: 5 additions & 4 deletions wedpr-components/admin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ plugins {
}

dependencies {
compile project(":wedpr-components-token-auth")
compile project(":wedpr-components-mybatis")
compile project(":wedpr-components-dataset")
compile project(":wedpr-components-sync")
implementation project(":wedpr-components-token-auth")
implementation project(":wedpr-components-mybatis")
implementation project(":wedpr-components-dataset")
implementation project(":wedpr-components-sync")
implementation project(":wedpr-components-transport")
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* 前端控制器
*
* @author caryliao
* @since 2024-08-22
* @since 2024-09-04
*/
@RestController
@RequestMapping("/admin/wedprJobTable")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,48 @@
package com.webank.wedpr.components.admin.controller;

import com.webank.wedpr.components.admin.common.Utils;
import com.webank.wedpr.components.admin.request.GetWedprProjectListRequest;
import com.webank.wedpr.components.admin.response.ListProjectResponse;
import com.webank.wedpr.components.admin.service.WedprProjectTableService;
import com.webank.wedpr.components.token.auth.model.UserToken;
import com.webank.wedpr.core.utils.Constant;
import com.webank.wedpr.core.utils.WeDPRResponse;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
* 前端控制器
*
* @author caryliao
* @since 2024-08-22
* @since 2024-09-04
*/
@RestController
@RequestMapping("/admin/wedprProjectTable")
public class WedprProjectTableController {}
@RequestMapping(
path = Constant.WEDPR_API_PREFIX + "/admin",
produces = {"application/json"})
@Slf4j
public class WedprProjectTableController {
@Autowired private WedprProjectTableService wedprProjectTableService;

@GetMapping("/listProject")
public WeDPRResponse listProject(
@Valid GetWedprProjectListRequest getWedprProjectListRequest,
HttpServletRequest request) {
try {
// check user permission
UserToken userToken = Utils.checkPermission(request);
ListProjectResponse listProjectResponse =
wedprProjectTableService.listProject(getWedprProjectListRequest);
return new WeDPRResponse(
Constant.WEDPR_SUCCESS, Constant.WEDPR_SUCCESS_MSG, listProjectResponse);
} catch (Exception e) {
log.error("listProject error", e);
return new WeDPRResponse(Constant.WEDPR_FAILED, e.getMessage());
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.webank.wedpr.components.admin.entity;

import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
Expand All @@ -8,7 +9,7 @@

/**
* @author caryliao
* @since 2024-08-22
* @since 2024-09-04
*/
@TableName("wedpr_job_table")
@ApiModel(value = "WedprJobTable对象", description = "")
Expand All @@ -17,6 +18,7 @@ public class WedprJobTable implements Serializable {
private static final long serialVersionUID = 1L;

@ApiModelProperty(value = "任务ID")
@TableId("id")
private String id;

@ApiModelProperty(value = "任务名称")
Expand Down Expand Up @@ -46,6 +48,9 @@ public class WedprJobTable implements Serializable {
@ApiModelProperty(value = "任务执行结果(json)")
private String jobResult;

@ApiModelProperty(value = "上报状态")
private Integer reportStatus;

@ApiModelProperty(value = "任务创建时间")
private LocalDateTime createTime;

Expand Down Expand Up @@ -132,6 +137,14 @@ public void setJobResult(String jobResult) {
this.jobResult = jobResult;
}

public Integer getReportStatus() {
return reportStatus;
}

public void setReportStatus(Integer reportStatus) {
this.reportStatus = reportStatus;
}

public LocalDateTime getCreateTime() {
return createTime;
}
Expand Down Expand Up @@ -171,6 +184,8 @@ public String toString() {
+ status
+ ", jobResult="
+ jobResult
+ ", reportStatus="
+ reportStatus
+ ", createTime="
+ createTime
+ ", lastUpdateTime="
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.webank.wedpr.components.admin.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
Expand All @@ -8,7 +10,7 @@

/**
* @author caryliao
* @since 2024-08-22
* @since 2024-09-04
*/
@TableName("wedpr_project_table")
@ApiModel(value = "WedprProjectTable对象", description = "")
Expand All @@ -17,12 +19,14 @@ public class WedprProjectTable implements Serializable {
private static final long serialVersionUID = 1L;

@ApiModelProperty(value = "项目ID")
@TableId("id")
private String id;

@ApiModelProperty(value = "项目名称")
private String name;

@ApiModelProperty(value = "项目描述")
@TableField("`desc`")
private String desc;

@ApiModelProperty(value = "项目属主")
Expand All @@ -37,6 +41,9 @@ public class WedprProjectTable implements Serializable {
@ApiModelProperty(value = "项目标签")
private String label;

@ApiModelProperty(value = "上报状态")
private Integer reportStatus;

@ApiModelProperty(value = "项目创建时间")
private LocalDateTime createTime;

Expand Down Expand Up @@ -99,6 +106,14 @@ public void setLabel(String label) {
this.label = label;
}

public Integer getReportStatus() {
return reportStatus;
}

public void setReportStatus(Integer reportStatus) {
this.reportStatus = reportStatus;
}

public LocalDateTime getCreateTime() {
return createTime;
}
Expand Down Expand Up @@ -132,6 +147,8 @@ public String toString() {
+ projectType
+ ", label="
+ label
+ ", reportStatus="
+ reportStatus
+ ", createTime="
+ createTime
+ ", lastUpdateTime="
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
* Mapper 接口
*
* @author caryliao
* @since 2024-08-22
* @since 2024-09-04
*/
public interface WedprJobTableMapper extends BaseMapper<WedprJobTable> {}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
* Mapper 接口
*
* @author caryliao
* @since 2024-08-22
* @since 2024-09-04
*/
public interface WedprProjectTableMapper extends BaseMapper<WedprProjectTable> {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.webank.wedpr.components.admin.request;

import com.webank.wedpr.core.utils.Constant;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import lombok.Data;

@Data
public class GetWedprProjectListRequest {
private String ownerAgencyName;
private String projectName;
private String startTime;
private String endTime;
private Integer pageNum = Constant.DEFAULT_PAGE_NUM;

@Min(value = 5, message = "分页条数最小不能小于5")
@Max(value = 10000, message = "分页条数最大不能大于10000")
private Integer pageSize = Constant.DEFAULT_PAGE_SIZE;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.webank.wedpr.components.admin.response;

import com.webank.wedpr.components.admin.entity.WedprProjectTable;
import java.util.List;
import lombok.Data;

/** Created by caryliao on 2024/9/5 9:35 */
@Data
public class ListProjectResponse {
private Long total;
private List<WedprProjectTable> projectList;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
* 服务类
*
* @author caryliao
* @since 2024-08-22
* @since 2024-09-04
*/
public interface WedprJobTableService extends IService<WedprJobTable> {}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@

import com.baomidou.mybatisplus.extension.service.IService;
import com.webank.wedpr.components.admin.entity.WedprProjectTable;
import com.webank.wedpr.components.admin.request.GetWedprProjectListRequest;
import com.webank.wedpr.components.admin.response.ListProjectResponse;

/**
* 服务类
*
* @author caryliao
* @since 2024-08-22
* @since 2024-09-04
*/
public interface WedprProjectTableService extends IService<WedprProjectTable> {}
public interface WedprProjectTableService extends IService<WedprProjectTable> {

ListProjectResponse listProject(GetWedprProjectListRequest getWedprProjectListRequest);
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* 服务实现类
*
* @author caryliao
* @since 2024-08-22
* @since 2024-09-04
*/
@Service
public class WedprJobTableServiceImpl extends ServiceImpl<WedprJobTableMapper, WedprJobTable>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,58 @@
package com.webank.wedpr.components.admin.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.webank.wedpr.components.admin.common.Utils;
import com.webank.wedpr.components.admin.entity.WedprProjectTable;
import com.webank.wedpr.components.admin.mapper.WedprProjectTableMapper;
import com.webank.wedpr.components.admin.request.GetWedprProjectListRequest;
import com.webank.wedpr.components.admin.response.ListProjectResponse;
import com.webank.wedpr.components.admin.service.WedprProjectTableService;
import java.time.LocalDateTime;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
* 服务实现类
*
* @author caryliao
* @since 2024-08-22
* @since 2024-09-04
*/
@Service
public class WedprProjectTableServiceImpl
extends ServiceImpl<WedprProjectTableMapper, WedprProjectTable>
implements WedprProjectTableService {}
implements WedprProjectTableService {

@Override
public ListProjectResponse listProject(GetWedprProjectListRequest request) {
LambdaQueryWrapper<WedprProjectTable> lambdaQueryWrapper = new LambdaQueryWrapper<>();
String ownerAgencyName = request.getOwnerAgencyName();
String projectName = request.getProjectName();
String startTimeStr = request.getStartTime();
String endTimeStr = request.getEndTime();
Integer pageNum = request.getPageNum();
Integer pageSize = request.getPageSize();
if (!StringUtils.isEmpty(ownerAgencyName)) {
lambdaQueryWrapper.like(WedprProjectTable::getOwnerAgency, ownerAgencyName);
}
if (!StringUtils.isEmpty(projectName)) {
lambdaQueryWrapper.like(WedprProjectTable::getName, projectName);
}
if (!StringUtils.isEmpty(startTimeStr)) {
LocalDateTime startTime = Utils.getLocalDateTime(startTimeStr);
lambdaQueryWrapper.ge(WedprProjectTable::getCreateTime, startTime);
}
if (!StringUtils.isEmpty(endTimeStr)) {
LocalDateTime endTime = Utils.getLocalDateTime(endTimeStr);
lambdaQueryWrapper.le(WedprProjectTable::getCreateTime, endTime);
}
lambdaQueryWrapper.orderByDesc(WedprProjectTable::getLastUpdateTime);
Page<WedprProjectTable> projectTablePage = new Page<>(pageNum, pageSize);
Page<WedprProjectTable> page = page(projectTablePage, lambdaQueryWrapper);
ListProjectResponse listProjectResponse = new ListProjectResponse();
listProjectResponse.setTotal(page.getTotal());
listProjectResponse.setProjectList(page.getRecords());
return listProjectResponse;
}
}
Loading

0 comments on commit 34fbc9e

Please sign in to comment.