代码优化
This commit is contained in:
@@ -31,8 +31,12 @@ import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
@@ -44,13 +48,13 @@ import org.springframework.web.util.UriComponentsBuilder;
|
||||
@Controller
|
||||
@RequestMapping(value={"/api/idm/Organization"})
|
||||
public class RestOrganizationController {
|
||||
final static Logger _logger = LoggerFactory.getLogger(RestOrganizationController.class);
|
||||
static final Logger _logger = LoggerFactory.getLogger(RestOrganizationController.class);
|
||||
|
||||
@Autowired
|
||||
OrganizationsService organizationsService;
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
|
||||
@GetMapping(value = "/{id}")
|
||||
public Organizations getUser(@PathVariable String id,
|
||||
@RequestParam(required = false) String attributes) {
|
||||
_logger.debug("Organizations id {} , attributes {}", id , attributes);
|
||||
@@ -59,7 +63,7 @@ public class RestOrganizationController {
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(method = RequestMethod.POST)
|
||||
@PostMapping
|
||||
public Organizations create(@RequestBody Organizations org,
|
||||
@RequestParam(required = false) String attributes,
|
||||
UriComponentsBuilder builder) throws IOException {
|
||||
@@ -74,7 +78,7 @@ public class RestOrganizationController {
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.PUT)
|
||||
@PutMapping(value = "/{id}")
|
||||
public Organizations replace(@PathVariable String id,
|
||||
@RequestBody Organizations org,
|
||||
@RequestParam(required = false) String attributes)
|
||||
@@ -90,7 +94,7 @@ public class RestOrganizationController {
|
||||
return org;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
|
||||
@DeleteMapping(value = "/{id}")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public void delete(@PathVariable final String id) {
|
||||
_logger.debug("Organizations id {} ", id );
|
||||
@@ -98,7 +102,7 @@ public class RestOrganizationController {
|
||||
|
||||
}
|
||||
|
||||
@RequestMapping(value = { "/.search" }, produces = {MediaType.APPLICATION_JSON_VALUE})
|
||||
@GetMapping(value = { "/.search" }, produces = {MediaType.APPLICATION_JSON_VALUE})
|
||||
@ResponseBody
|
||||
public ResponseEntity<?> search(@ModelAttribute Organizations org) {
|
||||
if(StringUtils.isBlank(org.getInstId())){
|
||||
|
||||
@@ -20,7 +20,6 @@ package org.dromara.maxkey.web.apis.identity.rest;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.dromara.maxkey.entity.ChangePassword;
|
||||
import org.dromara.maxkey.entity.Message;
|
||||
import org.dromara.maxkey.entity.UserInfo;
|
||||
import org.dromara.maxkey.persistence.service.UserInfoService;
|
||||
@@ -33,11 +32,14 @@ import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
@@ -47,13 +49,13 @@ import org.springframework.web.util.UriComponentsBuilder;
|
||||
@RequestMapping(value={"/api/idm/Users"})
|
||||
public class RestUserInfoController {
|
||||
|
||||
final static Logger _logger = LoggerFactory.getLogger(RestUserInfoController.class);
|
||||
static final Logger _logger = LoggerFactory.getLogger(RestUserInfoController.class);
|
||||
|
||||
@Autowired
|
||||
@Qualifier("userInfoService")
|
||||
private UserInfoService userInfoService;
|
||||
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
|
||||
@GetMapping(value = "/{id}")
|
||||
@ResponseBody
|
||||
public UserInfo getUser(
|
||||
@PathVariable String id,
|
||||
@@ -64,7 +66,7 @@ public class RestUserInfoController {
|
||||
return loadUserInfo;
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST)
|
||||
@PostMapping
|
||||
@ResponseBody
|
||||
public UserInfo create(@RequestBody UserInfo userInfo,
|
||||
@RequestParam(required = false) String attributes,
|
||||
@@ -79,26 +81,7 @@ public class RestUserInfoController {
|
||||
return userInfo;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/changePassword",method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public String changePassword(
|
||||
@RequestParam(required = true) String username,
|
||||
@RequestParam(required = true) String password,
|
||||
UriComponentsBuilder builder) throws IOException {
|
||||
|
||||
_logger.debug("UserInfo username {} , password {}", username , password);
|
||||
|
||||
UserInfo loadUserInfo = userInfoService.findByUsername(username);
|
||||
if(loadUserInfo != null) {
|
||||
ChangePassword changePassword = new ChangePassword(loadUserInfo);
|
||||
changePassword.setPassword(password);
|
||||
changePassword.setDecipherable(loadUserInfo.getDecipherable());
|
||||
userInfoService.changePassword(changePassword,true);
|
||||
}
|
||||
return "true";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.PUT)
|
||||
@PutMapping(value = "/{id}")
|
||||
@ResponseBody
|
||||
public UserInfo replace(@PathVariable String id,
|
||||
@RequestBody UserInfo userInfo,
|
||||
@@ -114,14 +97,14 @@ public class RestUserInfoController {
|
||||
return userInfo;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
|
||||
@DeleteMapping(value = "/{id}")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public void delete(@PathVariable final String id) {
|
||||
_logger.debug("UserInfo id {} ", id );
|
||||
userInfoService.logicDelete(id);
|
||||
}
|
||||
|
||||
@RequestMapping(value = { "/.search" }, produces = {MediaType.APPLICATION_JSON_VALUE})
|
||||
@GetMapping(value = { "/.search" }, produces = {MediaType.APPLICATION_JSON_VALUE})
|
||||
@ResponseBody
|
||||
public ResponseEntity<?> search(@ModelAttribute UserInfo userInfo) {
|
||||
_logger.debug("UserInfo {}",userInfo);
|
||||
|
||||
Reference in New Issue
Block a user