|
|
@@ -15,100 +15,73 @@
|
|
|
*/
|
|
|
|
|
|
|
|
|
-package org.maxkey.web.contorller;
|
|
|
+package org.maxkey.web.config.contorller;
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
import org.apache.mybatis.jpa.persistence.JpaPageResults;
|
|
|
-import org.maxkey.constants.ConstsOperateMessage;
|
|
|
+import org.maxkey.authn.annotation.CurrentUser;
|
|
|
import org.maxkey.crypto.password.PasswordReciprocal;
|
|
|
+import org.maxkey.entity.Message;
|
|
|
import org.maxkey.entity.Synchronizers;
|
|
|
+import org.maxkey.entity.UserInfo;
|
|
|
import org.maxkey.persistence.service.SynchronizersService;
|
|
|
import org.maxkey.synchronizer.ISynchronizerService;
|
|
|
import org.maxkey.util.StringUtils;
|
|
|
import org.maxkey.web.WebContext;
|
|
|
-import org.maxkey.web.message.Message;
|
|
|
-import org.maxkey.web.message.MessageType;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
+import org.springframework.http.MediaType;
|
|
|
+import org.springframework.http.ResponseEntity;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
-import org.springframework.web.bind.annotation.ModelAttribute;
|
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
-import org.springframework.web.servlet.ModelAndView;
|
|
|
-
|
|
|
|
|
|
@Controller
|
|
|
-@RequestMapping(value={"/synchronizers"})
|
|
|
+@RequestMapping(value={"/config/synchronizers"})
|
|
|
public class SynchronizersController {
|
|
|
final static Logger _logger = LoggerFactory.getLogger(SynchronizersController.class);
|
|
|
|
|
|
@Autowired
|
|
|
- @Qualifier("synchronizersService")
|
|
|
SynchronizersService synchronizersService;
|
|
|
|
|
|
- @RequestMapping(value={"/list"})
|
|
|
- public ModelAndView groupsList(){
|
|
|
- return new ModelAndView("synchronizers/synchronizersList");
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- @RequestMapping(value = { "/grid" })
|
|
|
+ @RequestMapping(value = { "/fetch" }, produces = {MediaType.APPLICATION_JSON_VALUE})
|
|
|
@ResponseBody
|
|
|
- public JpaPageResults<Synchronizers> queryDataGrid(@ModelAttribute("synchronizers") Synchronizers synchronizers) {
|
|
|
+ public ResponseEntity<?> fetch(Synchronizers synchronizers,@CurrentUser UserInfo currentUser) {
|
|
|
_logger.debug(""+synchronizers);
|
|
|
- synchronizers.setInstId(WebContext.getUserInfo().getInstId());
|
|
|
- return synchronizersService.queryPageResults(synchronizers);
|
|
|
+ synchronizers.setInstId(currentUser.getInstId());
|
|
|
+ return new Message<JpaPageResults<Synchronizers>>(
|
|
|
+ synchronizersService.queryPageResults(synchronizers)).buildResponse();
|
|
|
}
|
|
|
-
|
|
|
|
|
|
-
|
|
|
-
|
|
|
- @RequestMapping(value = { "/forwardUpdate/{id}" })
|
|
|
- public ModelAndView forwardUpdate(@PathVariable("id") String id) {
|
|
|
- ModelAndView modelAndView=new ModelAndView("synchronizers/synchronizerUpdate");
|
|
|
+ @RequestMapping(value = { "/get/{id}" }, produces = {MediaType.APPLICATION_JSON_VALUE})
|
|
|
+ public ResponseEntity<?> get(@PathVariable("id") String id) {
|
|
|
Synchronizers synchronizers=synchronizersService.get(id);
|
|
|
synchronizers.setCredentials(PasswordReciprocal.getInstance().decoder(synchronizers.getCredentials()));
|
|
|
- modelAndView.addObject("model",synchronizers);
|
|
|
- return modelAndView;
|
|
|
+ return new Message<Synchronizers>(synchronizers).buildResponse();
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 修改
|
|
|
- * @param group
|
|
|
- * @return
|
|
|
- */
|
|
|
@ResponseBody
|
|
|
- @RequestMapping(value={"/update"})
|
|
|
- public Message update(@ModelAttribute("synchronizers") Synchronizers synchronizers) {
|
|
|
- _logger.debug("-update synchronizers :" + synchronizers);
|
|
|
- synchronizers.setInstId(WebContext.getUserInfo().getInstId());
|
|
|
+ @RequestMapping(value={"/update"}, produces = {MediaType.APPLICATION_JSON_VALUE})
|
|
|
+ public ResponseEntity<?> update(@RequestBody Synchronizers synchronizers,@CurrentUser UserInfo currentUser) {
|
|
|
+ _logger.debug("-update :" + synchronizers);
|
|
|
+ synchronizers.setInstId(currentUser.getInstId());
|
|
|
synchronizers.setCredentials(PasswordReciprocal.getInstance().encode(synchronizers.getCredentials()));
|
|
|
if (synchronizersService.update(synchronizers)) {
|
|
|
- return new Message(WebContext.getI18nValue(ConstsOperateMessage.UPDATE_SUCCESS),MessageType.success);
|
|
|
-
|
|
|
+ return new Message<Synchronizers>(Message.SUCCESS).buildResponse();
|
|
|
} else {
|
|
|
- return new Message(WebContext.getI18nValue(ConstsOperateMessage.UPDATE_ERROR),MessageType.error);
|
|
|
+ return new Message<Synchronizers>(Message.FAIL).buildResponse();
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 修改
|
|
|
- * @param group
|
|
|
- * @return
|
|
|
- */
|
|
|
@ResponseBody
|
|
|
@RequestMapping(value={"/sync"})
|
|
|
- public Message sync(@RequestParam("id") String id) {
|
|
|
- _logger.debug("-update synchronizers ids :" + id);
|
|
|
+ public ResponseEntity<?> sync(@RequestParam("id") String id) {
|
|
|
+ _logger.debug("-sync ids :" + id);
|
|
|
|
|
|
List<String> ids = StringUtils.string2List(id, ",");
|
|
|
try {
|
|
|
@@ -122,9 +95,10 @@ public class SynchronizersController {
|
|
|
}
|
|
|
}catch(Exception e) {
|
|
|
_logger.error("synchronizer Exception " , e);
|
|
|
- return new Message(WebContext.getI18nValue(ConstsOperateMessage.UPDATE_ERROR),MessageType.error);
|
|
|
+ return new Message<Synchronizers>(Message.FAIL).buildResponse();
|
|
|
+
|
|
|
}
|
|
|
- return new Message(WebContext.getI18nValue(ConstsOperateMessage.UPDATE_SUCCESS),MessageType.success);
|
|
|
+ return new Message<Synchronizers>(Message.SUCCESS).buildResponse();
|
|
|
}
|
|
|
|
|
|
}
|