Skip to content

Commit

Permalink
Merge pull request #47 from fqliao/feature-milestone2
Browse files Browse the repository at this point in the history
add listJob && queryJobByDataset && sys config api for admin
  • Loading branch information
fqliao authored Sep 9, 2024
2 parents e030f06 + 2a0a4db commit 27b2ac2
Show file tree
Hide file tree
Showing 43 changed files with 819 additions and 241 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ wedpr-components/user/src/main/resources/
wedpr-adm/src/main/resources/
wedpr-admin/src/main/resources/
logs/
bin/
bin/
**/GenerateCodeMain2.java
4 changes: 3 additions & 1 deletion db/wedpr_admin_dml.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
-- 管理端初始化
insert into wedpr_user (username, password, status) values('admin', '{bcrypt}$2a$10$XuiuKLg23kxtC/ldvYN0/evt0Y3aoBC9iV29srhIBMMDORzCQiYA.', 0);
insert into wedpr_user_role(username, role_id) values ('admin', '10');
insert into wedpr_role_permission (role_id, role_name, permission_id) values ('10', 'admin_user', '1');
insert into wedpr_role_permission (role_id, role_name, permission_id) values ('10', 'admin_user', '1');

insert into `wedpr_config_table`(`config_key`, `config_value`) values("wedpr_algorithm_templates", '{"version":"1.0","templates":[{"name":"PSI","title":"数据对齐","detail":"","version":"1.0"},{"name":"XGB_TRAINING","title":"SecureLGBM训练","detail":"","version":"1.0"},{"name":"XGB_PREDICTING","title":"SecureLGBM预测","detail":"","version":"1.0"}]}');
8 changes: 6 additions & 2 deletions db/wedpr_ddl.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ create table if not exists `wedpr_agency_table`(
create table if not exists `wedpr_config_table`(
`config_key` varchar(128) not null comment "配置项主键",
`config_value` longtext not null 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(`config_key`)
primary key(`config_key`),
index report_status_index(`report_status`)
)ENGINE=InnoDB default charset=utf8mb4 default collate=utf8mb4_bin ROW_FORMAT=DYNAMIC;

-- the sync table(record the sync status of all resources)
Expand Down Expand Up @@ -142,9 +144,11 @@ create table if not exists `wedpr_job_table`(
create table if not exists `wedpr_job_dataset_relation`(
`job_id` varchar(64) not null comment "任务ID",
`dataset_id` varchar(64) not null comment "数据集ID",
`report_status` tinyint default 0 comment "上报状态",
`create_time` DATETIME DEFAULT CURRENT_TIMESTAMP comment "任务创建时间",
index job_id_index(`job_id`),
index dataset_id_index(`dataset_id`)
index dataset_id_index(`dataset_id`),
index report_status_index(`report_status`)
)ENGINE=InnoDB default charset=utf8mb4 default collate=utf8mb4_bin ROW_FORMAT=DYNAMIC;

-- the algorithm_setting template
Expand Down
1 change: 1 addition & 0 deletions wedpr-adm/conf/wedpr.properties
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ wedpr.leader.election.expire.seconds=60

### the sync module related configuration
wedpr.agency=WeBank
wedpr.admin_agency=ADMIN
wedpr.sync.recorder.factory.contract_address=0x4721d1a77e0e76851d460073e64ea06d9c104194
wedpr.sync.sequencer.contract_address=0x6849f21d1e455e9f0712b1e99fa4fcd23758e8f1
wedpr.sync.recorder.contract_version=1
Expand Down
1 change: 1 addition & 0 deletions wedpr-admin/conf/wedpr.properties
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ wedpr.leader.election.expire.seconds=60

### the sync module related configuration
wedpr.agency=WeBank
wedpr.admin_agency=ADMIN
wedpr.sync.recorder.factory.contract_address=0x4721d1a77e0e76851d460073e64ea06d9c104194
wedpr.sync.sequencer.contract_address=0x6849f21d1e455e9f0712b1e99fa4fcd23758e8f1
wedpr.sync.recorder.contract_version=1
Expand Down
214 changes: 0 additions & 214 deletions wedpr-admin/db/wedpr_admin_ddl.sql

This file was deleted.

1 change: 1 addition & 0 deletions wedpr-components/admin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ dependencies {
implementation project(":wedpr-components-mybatis")
implementation project(":wedpr-components-dataset")
implementation project(":wedpr-components-sync")
implementation project(":wedpr-components-sys-config")
implementation project(":wedpr-components-transport")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.webank.wedpr.components.admin.controller;

import com.webank.wedpr.components.meta.sys.config.service.SysConfigService;
import com.webank.wedpr.core.utils.Constant;
import com.webank.wedpr.core.utils.WeDPRResponse;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
* 前端控制器
*
* @author caryliao
* @since 2024-09-07
*/
@RestController
@RequestMapping(
path = Constant.WEDPR_API_PREFIX + "/admin",
produces = {"application/json"})
@Slf4j
public class WedprConfigTableController {
@Autowired private SysConfigService sysConfigService;

@GetMapping("/getConfig")
public WeDPRResponse getSystemConfig(@RequestParam String key) {
try {
return sysConfigService.getSystemConfig(key);
} catch (Exception e) {
log.warn("getSystemConfig exception, key: {}, error: ", key, e);
return new WeDPRResponse(
Constant.WEDPR_FAILED, "getSystemConfig failed for " + e.getMessage());
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.webank.wedpr.components.admin.controller;

import com.webank.wedpr.components.admin.common.Utils;
import com.webank.wedpr.components.admin.request.GetJobByDatasetRequest;
import com.webank.wedpr.components.admin.response.ListJobResponse;
import com.webank.wedpr.components.admin.service.WedprJobDatasetRelationService;
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-09-06
*/
@RestController
@RequestMapping(
path = Constant.WEDPR_API_PREFIX + "/admin",
produces = {"application/json"})
@Slf4j
public class WedprJobDatasetRelationController {
@Autowired private WedprJobDatasetRelationService wedprJobDatasetRelationService;

@GetMapping("/queryJobsByDatasetId")
public WeDPRResponse queryJobsByDatasetId(
@Valid GetJobByDatasetRequest getJobByDatasetRequest, HttpServletRequest request) {
try {
// check user permission
UserToken userToken = Utils.checkPermission(request);
ListJobResponse listJobResponse =
wedprJobDatasetRelationService.queryJobsByDatasetId(getJobByDatasetRequest);
return new WeDPRResponse(
Constant.WEDPR_SUCCESS, Constant.WEDPR_SUCCESS_MSG, listJobResponse);
} catch (Exception e) {
log.error("getJobByDatasetId error", e);
return new WeDPRResponse(Constant.WEDPR_FAILED, e.getMessage());
}
}
}
Loading

0 comments on commit 27b2ac2

Please sign in to comment.