|
|
@@ -20,10 +20,8 @@ package org.dromara.maxkey.web.config.controller;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.dromara.maxkey.authn.annotation.CurrentUser;
|
|
|
import org.dromara.maxkey.crypto.password.PasswordReciprocal;
|
|
|
-import org.dromara.maxkey.entity.*;
|
|
|
import org.dromara.maxkey.persistence.service.SynchronizersService;
|
|
|
import org.dromara.maxkey.synchronizer.ISynchronizerService;
|
|
|
-import org.dromara.maxkey.synchronizer.service.SyncJobConfigFieldService;
|
|
|
import org.dromara.maxkey.entity.Connectors;
|
|
|
import org.dromara.maxkey.entity.Message;
|
|
|
import org.dromara.maxkey.entity.Synchronizers;
|
|
|
@@ -32,12 +30,10 @@ import org.dromara.maxkey.util.StrUtils;
|
|
|
import org.dromara.maxkey.web.WebContext;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
-import org.springframework.http.ResponseEntity;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.http.MediaType;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
-import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
|
@RestController
|
|
|
@@ -48,9 +44,6 @@ public class SynchronizersController {
|
|
|
@Autowired
|
|
|
SynchronizersService synchronizersService;
|
|
|
|
|
|
- @Autowired
|
|
|
- SyncJobConfigFieldService syncJobConfigFieldService;
|
|
|
-
|
|
|
@RequestMapping(value = {"/fetch"}, produces = {MediaType.APPLICATION_JSON_VALUE})
|
|
|
@ResponseBody
|
|
|
public Message<?> fetch(Synchronizers synchronizers, @CurrentUser UserInfo currentUser) {
|
|
|
@@ -61,8 +54,8 @@ public class SynchronizersController {
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value = {"/get/{id}"}, produces = {MediaType.APPLICATION_JSON_VALUE})
|
|
|
- public Message<?> get(@PathVariable String id) {
|
|
|
- Synchronizers synchronizers = synchronizersService.get(id);
|
|
|
+ public Message<?> get(@PathVariable String id, @CurrentUser UserInfo currentUser) {
|
|
|
+ Synchronizers synchronizers = synchronizersService.get(id,currentUser.getInstId());
|
|
|
synchronizers.setCredentials(PasswordReciprocal.getInstance().decoder(synchronizers.getCredentials()));
|
|
|
return new Message<>(synchronizers);
|
|
|
}
|
|
|
@@ -97,9 +90,9 @@ public class SynchronizersController {
|
|
|
|
|
|
@ResponseBody
|
|
|
@RequestMapping(value = {"/delete"}, produces = {MediaType.APPLICATION_JSON_VALUE})
|
|
|
- public Message<?> delete(@RequestParam List<String> ids) {
|
|
|
+ public Message<?> delete(@RequestParam List<String> ids, @CurrentUser UserInfo currentUser) {
|
|
|
logger.debug("-delete ids : {} ", ids);
|
|
|
- if (synchronizersService.deleteBatch(ids)) {
|
|
|
+ if (synchronizersService.deleteBatch(ids,currentUser.getInstId())) {
|
|
|
return new Message<Connectors>(Message.SUCCESS);
|
|
|
} else {
|
|
|
return new Message<Connectors>(Message.FAIL);
|
|
|
@@ -108,13 +101,13 @@ public class SynchronizersController {
|
|
|
|
|
|
@ResponseBody
|
|
|
@RequestMapping(value = {"/synchr"})
|
|
|
- public Message<?> synchr(@RequestParam String id) {
|
|
|
+ public Message<?> synchr(@RequestParam String id, @CurrentUser UserInfo currentUser) {
|
|
|
logger.debug("-sync ids : {}", id);
|
|
|
|
|
|
List<String> ids = StrUtils.string2List(id, ",");
|
|
|
try {
|
|
|
for (String sysId : ids) {
|
|
|
- Synchronizers synchronizer = synchronizersService.get(sysId);
|
|
|
+ Synchronizers synchronizer = synchronizersService.get(sysId,currentUser.getInstId());
|
|
|
synchronizer.setCredentials(PasswordReciprocal.getInstance().decoder(synchronizer.getCredentials()));
|
|
|
logger.debug("synchronizer {}", synchronizer);
|
|
|
ISynchronizerService synchronizerService = WebContext.getBean(synchronizer.getService(), ISynchronizerService.class);
|
|
|
@@ -133,53 +126,4 @@ public class SynchronizersController {
|
|
|
return new Message<Synchronizers>(Message.SUCCESS);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- @RequestMapping(value = {"/mapping-list/{jobId}"}, produces = {MediaType.APPLICATION_JSON_VALUE})
|
|
|
- @ResponseBody
|
|
|
- public ResponseEntity<?> mapping(@PathVariable Long jobId) {
|
|
|
- logger.debug("mapping {}", jobId);
|
|
|
- List<SyncJobConfigField> syncJobConfigFields = syncJobConfigFieldService.findByJobId(jobId);
|
|
|
- return new Message<>(syncJobConfigFields).buildResponse();
|
|
|
- }
|
|
|
-
|
|
|
- @RequestMapping(value = {"/mapping-get/{id}"}, produces = {MediaType.APPLICATION_JSON_VALUE})
|
|
|
- @ResponseBody
|
|
|
- public ResponseEntity<?> mappingGet(@PathVariable Long id) {
|
|
|
- logger.debug("mapping get {}", id);
|
|
|
- SyncJobConfigField syncJobConfigFields = syncJobConfigFieldService.get(String.valueOf(id));
|
|
|
- return new Message<>(syncJobConfigFields).buildResponse();
|
|
|
- }
|
|
|
-
|
|
|
- @RequestMapping(value = {"/mapping-delete/{id}"}, produces = {MediaType.APPLICATION_JSON_VALUE})
|
|
|
- @ResponseBody
|
|
|
- public ResponseEntity<?> mappingDelete(@PathVariable Long id) {
|
|
|
- logger.debug("mappingDelete {}", id);
|
|
|
- syncJobConfigFieldService.deleteFieldMapById(id);
|
|
|
- return new Message<SyncJobConfigField>(Message.SUCCESS).buildResponse();
|
|
|
- }
|
|
|
-
|
|
|
- @ResponseBody
|
|
|
- @PostMapping(value = {"/mapping-add"}, produces = {MediaType.APPLICATION_JSON_VALUE})
|
|
|
- public ResponseEntity<?> mappingadd(@RequestBody SyncJobConfigField syncJobConfigField, @CurrentUser UserInfo currentUser) {
|
|
|
- logger.debug("-mapping add : {}", syncJobConfigField);
|
|
|
- syncJobConfigField.setCreateTime(new Date());
|
|
|
- if (syncJobConfigFieldService.insert(syncJobConfigField)) {
|
|
|
- return new Message<Synchronizers>(Message.SUCCESS).buildResponse();
|
|
|
- } else {
|
|
|
- return new Message<Synchronizers>(Message.FAIL).buildResponse();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @ResponseBody
|
|
|
- @PutMapping(value = {"/mapping-update"}, produces = {MediaType.APPLICATION_JSON_VALUE})
|
|
|
- public ResponseEntity<?> mappingupdate(@RequestBody SyncJobConfigField syncJobConfigField, @CurrentUser UserInfo currentUser) {
|
|
|
- logger.debug("-mapping update : {}", syncJobConfigField);
|
|
|
- syncJobConfigField.setUpdateTime(new Date());
|
|
|
- if (syncJobConfigFieldService.update(syncJobConfigField)) {
|
|
|
- return new Message<Synchronizers>(Message.SUCCESS).buildResponse();
|
|
|
- } else {
|
|
|
- return new Message<Synchronizers>(Message.FAIL).buildResponse();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
}
|