Skip to content

Commit 27b2ac2

Browse files
authored
Merge pull request #47 from fqliao/feature-milestone2
add listJob && queryJobByDataset && sys config api for admin
2 parents e030f06 + 2a0a4db commit 27b2ac2

File tree

43 files changed

+819
-241
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+819
-241
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ wedpr-components/user/src/main/resources/
66
wedpr-adm/src/main/resources/
77
wedpr-admin/src/main/resources/
88
logs/
9-
bin/
9+
bin/
10+
**/GenerateCodeMain2.java

db/wedpr_admin_dml.sql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
-- 管理端初始化
22
insert into wedpr_user (username, password, status) values('admin', '{bcrypt}$2a$10$XuiuKLg23kxtC/ldvYN0/evt0Y3aoBC9iV29srhIBMMDORzCQiYA.', 0);
33
insert into wedpr_user_role(username, role_id) values ('admin', '10');
4-
insert into wedpr_role_permission (role_id, role_name, permission_id) values ('10', 'admin_user', '1');
4+
insert into wedpr_role_permission (role_id, role_name, permission_id) values ('10', 'admin_user', '1');
5+
6+
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"}]}');

db/wedpr_ddl.sql

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@ create table if not exists `wedpr_agency_table`(
1414
create table if not exists `wedpr_config_table`(
1515
`config_key` varchar(128) not null comment "配置项主键",
1616
`config_value` longtext not null comment "配置项的值",
17+
`report_status` tinyint default 0 comment "上报状态",
1718
`create_time` datetime DEFAULT CURRENT_TIMESTAMP comment "配置创建时间",
1819
`last_update_time` DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP comment "配置更新时间",
19-
primary key(`config_key`)
20+
primary key(`config_key`),
21+
index report_status_index(`report_status`)
2022
)ENGINE=InnoDB default charset=utf8mb4 default collate=utf8mb4_bin ROW_FORMAT=DYNAMIC;
2123

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

150154
-- the algorithm_setting template

wedpr-adm/conf/wedpr.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ wedpr.leader.election.expire.seconds=60
3737

3838
### the sync module related configuration
3939
wedpr.agency=WeBank
40+
wedpr.admin_agency=ADMIN
4041
wedpr.sync.recorder.factory.contract_address=0x4721d1a77e0e76851d460073e64ea06d9c104194
4142
wedpr.sync.sequencer.contract_address=0x6849f21d1e455e9f0712b1e99fa4fcd23758e8f1
4243
wedpr.sync.recorder.contract_version=1

wedpr-admin/conf/wedpr.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ wedpr.leader.election.expire.seconds=60
3232

3333
### the sync module related configuration
3434
wedpr.agency=WeBank
35+
wedpr.admin_agency=ADMIN
3536
wedpr.sync.recorder.factory.contract_address=0x4721d1a77e0e76851d460073e64ea06d9c104194
3637
wedpr.sync.sequencer.contract_address=0x6849f21d1e455e9f0712b1e99fa4fcd23758e8f1
3738
wedpr.sync.recorder.contract_version=1

wedpr-admin/db/wedpr_admin_ddl.sql

Lines changed: 0 additions & 214 deletions
This file was deleted.

wedpr-components/admin/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ dependencies {
88
implementation project(":wedpr-components-mybatis")
99
implementation project(":wedpr-components-dataset")
1010
implementation project(":wedpr-components-sync")
11+
implementation project(":wedpr-components-sys-config")
1112
implementation project(":wedpr-components-transport")
1213
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package com.webank.wedpr.components.admin.controller;
2+
3+
import com.webank.wedpr.components.meta.sys.config.service.SysConfigService;
4+
import com.webank.wedpr.core.utils.Constant;
5+
import com.webank.wedpr.core.utils.WeDPRResponse;
6+
import lombok.extern.slf4j.Slf4j;
7+
import org.springframework.beans.factory.annotation.Autowired;
8+
import org.springframework.web.bind.annotation.GetMapping;
9+
import org.springframework.web.bind.annotation.RequestMapping;
10+
import org.springframework.web.bind.annotation.RequestParam;
11+
import org.springframework.web.bind.annotation.RestController;
12+
13+
/**
14+
* 前端控制器
15+
*
16+
* @author caryliao
17+
* @since 2024-09-07
18+
*/
19+
@RestController
20+
@RequestMapping(
21+
path = Constant.WEDPR_API_PREFIX + "/admin",
22+
produces = {"application/json"})
23+
@Slf4j
24+
public class WedprConfigTableController {
25+
@Autowired private SysConfigService sysConfigService;
26+
27+
@GetMapping("/getConfig")
28+
public WeDPRResponse getSystemConfig(@RequestParam String key) {
29+
try {
30+
return sysConfigService.getSystemConfig(key);
31+
} catch (Exception e) {
32+
log.warn("getSystemConfig exception, key: {}, error: ", key, e);
33+
return new WeDPRResponse(
34+
Constant.WEDPR_FAILED, "getSystemConfig failed for " + e.getMessage());
35+
}
36+
}
37+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package com.webank.wedpr.components.admin.controller;
2+
3+
import com.webank.wedpr.components.admin.common.Utils;
4+
import com.webank.wedpr.components.admin.request.GetJobByDatasetRequest;
5+
import com.webank.wedpr.components.admin.response.ListJobResponse;
6+
import com.webank.wedpr.components.admin.service.WedprJobDatasetRelationService;
7+
import com.webank.wedpr.components.token.auth.model.UserToken;
8+
import com.webank.wedpr.core.utils.Constant;
9+
import com.webank.wedpr.core.utils.WeDPRResponse;
10+
import javax.servlet.http.HttpServletRequest;
11+
import javax.validation.Valid;
12+
import lombok.extern.slf4j.Slf4j;
13+
import org.springframework.beans.factory.annotation.Autowired;
14+
import org.springframework.web.bind.annotation.GetMapping;
15+
import org.springframework.web.bind.annotation.RequestMapping;
16+
import org.springframework.web.bind.annotation.RestController;
17+
18+
/**
19+
* 前端控制器
20+
*
21+
* @author caryliao
22+
* @since 2024-09-06
23+
*/
24+
@RestController
25+
@RequestMapping(
26+
path = Constant.WEDPR_API_PREFIX + "/admin",
27+
produces = {"application/json"})
28+
@Slf4j
29+
public class WedprJobDatasetRelationController {
30+
@Autowired private WedprJobDatasetRelationService wedprJobDatasetRelationService;
31+
32+
@GetMapping("/queryJobsByDatasetId")
33+
public WeDPRResponse queryJobsByDatasetId(
34+
@Valid GetJobByDatasetRequest getJobByDatasetRequest, HttpServletRequest request) {
35+
try {
36+
// check user permission
37+
UserToken userToken = Utils.checkPermission(request);
38+
ListJobResponse listJobResponse =
39+
wedprJobDatasetRelationService.queryJobsByDatasetId(getJobByDatasetRequest);
40+
return new WeDPRResponse(
41+
Constant.WEDPR_SUCCESS, Constant.WEDPR_SUCCESS_MSG, listJobResponse);
42+
} catch (Exception e) {
43+
log.error("getJobByDatasetId error", e);
44+
return new WeDPRResponse(Constant.WEDPR_FAILED, e.getMessage());
45+
}
46+
}
47+
}

0 commit comments

Comments
 (0)