api add logs

This commit is contained in:
MaxKey 2023-04-05 13:46:14 +08:00
parent ea59e26a54
commit 07fa7a0402
2 changed files with 19 additions and 3 deletions

View File

@ -21,6 +21,8 @@ import java.io.IOException;
import org.maxkey.entity.Organizations; import org.maxkey.entity.Organizations;
import org.maxkey.persistence.service.OrganizationsService; import org.maxkey.persistence.service.OrganizationsService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
@ -36,6 +38,7 @@ import org.springframework.web.util.UriComponentsBuilder;
@Controller @Controller
@RequestMapping(value={"/api/idm/Organization"}) @RequestMapping(value={"/api/idm/Organization"})
public class RestOrganizationController { public class RestOrganizationController {
final static Logger _logger = LoggerFactory.getLogger(RestOrganizationController.class);
@Autowired @Autowired
OrganizationsService organizationsService; OrganizationsService organizationsService;
@ -53,6 +56,7 @@ public class RestOrganizationController {
public Organizations create(@RequestBody Organizations org, public Organizations create(@RequestBody Organizations org,
@RequestParam(required = false) String attributes, @RequestParam(required = false) String attributes,
UriComponentsBuilder builder) throws IOException { UriComponentsBuilder builder) throws IOException {
_logger.debug("Organizations content {} , attributes {}", org , attributes);
Organizations loadOrg = organizationsService.get(org.getId()); Organizations loadOrg = organizationsService.get(org.getId());
if(loadOrg == null) { if(loadOrg == null) {
organizationsService.insert(org); organizationsService.insert(org);
@ -68,6 +72,7 @@ public class RestOrganizationController {
@RequestBody Organizations org, @RequestBody Organizations org,
@RequestParam(required = false) String attributes) @RequestParam(required = false) String attributes)
throws IOException { throws IOException {
_logger.debug("Organizations id {} , content {} , attributes {}", id , org , attributes);
Organizations loadOrg = organizationsService.get(id); Organizations loadOrg = organizationsService.get(id);
if(loadOrg == null) { if(loadOrg == null) {
organizationsService.insert(org); organizationsService.insert(org);
@ -81,6 +86,7 @@ public class RestOrganizationController {
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE) @RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
@ResponseStatus(HttpStatus.OK) @ResponseStatus(HttpStatus.OK)
public void delete(@PathVariable final String id) { public void delete(@PathVariable final String id) {
_logger.debug("Organizations id {} ", id );
organizationsService.remove(id); organizationsService.remove(id);
} }

View File

@ -22,6 +22,8 @@ import java.io.IOException;
import org.maxkey.entity.ChangePassword; import org.maxkey.entity.ChangePassword;
import org.maxkey.entity.UserInfo; import org.maxkey.entity.UserInfo;
import org.maxkey.persistence.service.UserInfoService; import org.maxkey.persistence.service.UserInfoService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
@ -39,6 +41,8 @@ import org.springframework.web.util.UriComponentsBuilder;
@RequestMapping(value={"/api/idm/Users"}) @RequestMapping(value={"/api/idm/Users"})
public class RestUserInfoController { public class RestUserInfoController {
final static Logger _logger = LoggerFactory.getLogger(RestUserInfoController.class);
@Autowired @Autowired
@Qualifier("userInfoService") @Qualifier("userInfoService")
private UserInfoService userInfoService; private UserInfoService userInfoService;
@ -59,6 +63,7 @@ public class RestUserInfoController {
public UserInfo create(@RequestBody UserInfo userInfo, public UserInfo create(@RequestBody UserInfo userInfo,
@RequestParam(required = false) String attributes, @RequestParam(required = false) String attributes,
UriComponentsBuilder builder) throws IOException { UriComponentsBuilder builder) throws IOException {
_logger.debug("UserInfo content {} , attributes {}", userInfo , attributes);
UserInfo loadUserInfo = userInfoService.findByUsername(userInfo.getUsername()); UserInfo loadUserInfo = userInfoService.findByUsername(userInfo.getUsername());
if(loadUserInfo != null) { if(loadUserInfo != null) {
userInfoService.update(userInfo); userInfoService.update(userInfo);
@ -74,7 +79,10 @@ public class RestUserInfoController {
@RequestParam(required = true) String username, @RequestParam(required = true) String username,
@RequestParam(required = true) String password, @RequestParam(required = true) String password,
UriComponentsBuilder builder) throws IOException { UriComponentsBuilder builder) throws IOException {
UserInfo loadUserInfo = userInfoService.findByUsername(username);
_logger.debug("UserInfo username {} , password {}", username , password);
UserInfo loadUserInfo = userInfoService.findByUsername(username);
if(loadUserInfo != null) { if(loadUserInfo != null) {
ChangePassword changePassword = new ChangePassword(loadUserInfo); ChangePassword changePassword = new ChangePassword(loadUserInfo);
changePassword.setPassword(password); changePassword.setPassword(password);
@ -90,6 +98,7 @@ public class RestUserInfoController {
@RequestBody UserInfo userInfo, @RequestBody UserInfo userInfo,
@RequestParam(required = false) String attributes) @RequestParam(required = false) String attributes)
throws IOException { throws IOException {
_logger.debug("UserInfo content {} , attributes {}", userInfo , attributes);
UserInfo loadUserInfo = userInfoService.findByUsername(userInfo.getUsername()); UserInfo loadUserInfo = userInfoService.findByUsername(userInfo.getUsername());
if(loadUserInfo != null) { if(loadUserInfo != null) {
userInfoService.update(userInfo); userInfoService.update(userInfo);
@ -102,6 +111,7 @@ public class RestUserInfoController {
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE) @RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
@ResponseStatus(HttpStatus.OK) @ResponseStatus(HttpStatus.OK)
public void delete(@PathVariable final String id) { public void delete(@PathVariable final String id) {
_logger.debug("UserInfo id {} ", id );
userInfoService.logicDelete(id); userInfoService.logicDelete(id);
} }
} }