diff --git a/src/main/java/com/monkeyk/sos/domain/user/UserRepository.java b/src/main/java/com/monkeyk/sos/domain/user/UserRepository.java index eaf2c57..03ed2d5 100644 --- a/src/main/java/com/monkeyk/sos/domain/user/UserRepository.java +++ b/src/main/java/com/monkeyk/sos/domain/user/UserRepository.java @@ -18,5 +18,8 @@ public interface UserRepository extends Repository { User findByUsername(String username); + /** + * 注意:产品化的设计此处应该有分页会更好 + */ List findUsersByUsername(String username); } \ No newline at end of file diff --git a/src/main/java/com/monkeyk/sos/service/impl/OauthServiceImpl.java b/src/main/java/com/monkeyk/sos/service/impl/OauthServiceImpl.java index 947aa6a..c165ea1 100644 --- a/src/main/java/com/monkeyk/sos/service/impl/OauthServiceImpl.java +++ b/src/main/java/com/monkeyk/sos/service/impl/OauthServiceImpl.java @@ -1,16 +1,14 @@ package com.monkeyk.sos.service.impl; -import com.monkeyk.sos.service.dto.OauthClientDetailsDto; import com.monkeyk.sos.domain.oauth.OauthClientDetails; import com.monkeyk.sos.domain.oauth.OauthRepository; import com.monkeyk.sos.service.OauthService; +import com.monkeyk.sos.service.dto.OauthClientDetailsDto; import com.monkeyk.sos.web.WebUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Propagation; -import org.springframework.transaction.annotation.Transactional; import java.util.List; @@ -27,38 +25,42 @@ public class OauthServiceImpl implements OauthService { private OauthRepository oauthRepository; @Override - @Transactional(readOnly = true) +// @Transactional(readOnly = true) public OauthClientDetails loadOauthClientDetails(String clientId) { return oauthRepository.findOauthClientDetails(clientId); } @Override - @Transactional(readOnly = true) +// @Transactional(readOnly = true) public List loadAllOauthClientDetailsDtos() { List clientDetailses = oauthRepository.findAllOauthClientDetails(); return OauthClientDetailsDto.toDtos(clientDetailses); } @Override - @Transactional(propagation = Propagation.REQUIRED) +// @Transactional(propagation = Propagation.REQUIRED) public void archiveOauthClientDetails(String clientId) { oauthRepository.updateOauthClientDetailsArchive(clientId, true); - LOG.debug("{}|Update OauthClientDetails(clientId: {}) archive = true", WebUtils.getIp(), clientId); + if (LOG.isDebugEnabled()) { + LOG.debug("{}|Update OauthClientDetails(clientId: {}) archive = true", WebUtils.getIp(), clientId); + } } @Override - @Transactional(readOnly = true) +// @Transactional(readOnly = true) public OauthClientDetailsDto loadOauthClientDetailsDto(String clientId) { final OauthClientDetails oauthClientDetails = oauthRepository.findOauthClientDetails(clientId); return oauthClientDetails != null ? new OauthClientDetailsDto(oauthClientDetails) : null; } @Override - @Transactional(propagation = Propagation.REQUIRED) +// @Transactional(propagation = Propagation.REQUIRED) public void registerClientDetails(OauthClientDetailsDto formDto) { OauthClientDetails clientDetails = formDto.createDomain(); oauthRepository.saveOauthClientDetails(clientDetails); - LOG.debug("{}|Save OauthClientDetails: {}", WebUtils.getIp(), clientDetails); + if (LOG.isDebugEnabled()) { + LOG.debug("{}|Save OauthClientDetails: {}", WebUtils.getIp(), clientDetails); + } } } \ No newline at end of file diff --git a/src/main/java/com/monkeyk/sos/service/impl/UserServiceImpl.java b/src/main/java/com/monkeyk/sos/service/impl/UserServiceImpl.java index 1293448..bb5f9f1 100644 --- a/src/main/java/com/monkeyk/sos/service/impl/UserServiceImpl.java +++ b/src/main/java/com/monkeyk/sos/service/impl/UserServiceImpl.java @@ -1,28 +1,23 @@ package com.monkeyk.sos.service.impl; -import com.monkeyk.sos.service.dto.UserDto; -import com.monkeyk.sos.service.dto.UserFormDto; -import com.monkeyk.sos.service.dto.UserJsonDto; -import com.monkeyk.sos.service.dto.UserOverviewDto; import com.monkeyk.sos.domain.shared.security.SOSUserDetails; import com.monkeyk.sos.domain.user.User; import com.monkeyk.sos.domain.user.UserRepository; import com.monkeyk.sos.service.UserService; +import com.monkeyk.sos.service.dto.UserDto; +import com.monkeyk.sos.service.dto.UserFormDto; +import com.monkeyk.sos.service.dto.UserJsonDto; +import com.monkeyk.sos.service.dto.UserOverviewDto; import com.monkeyk.sos.web.WebUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.core.Authentication; -import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.core.userdetails.UserDetails; import org.springframework.security.core.userdetails.UsernameNotFoundException; - import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Propagation; -import org.springframework.transaction.annotation.Transactional; -import java.util.Collection; import java.util.List; /** @@ -59,11 +54,14 @@ public class UserServiceImpl implements UserService { // (principal instanceof String || principal instanceof org.springframework.security.core.userdetails.User)) { // return loadOauthUserJsonDto((OAuth2Authentication) authentication); // } else { - final SOSUserDetails userDetails = (SOSUserDetails) principal; - return new UserJsonDto(userRepository.findByGuid(userDetails.user().guid())); + final SOSUserDetails userDetails = (SOSUserDetails) principal; + return new UserJsonDto(userRepository.findByGuid(userDetails.user().guid())); // } } + /** + * 注意:产品化的设计此处应该有分页会更好 + */ @Override // @Transactional(readOnly = true) public UserOverviewDto loadUserOverviewDto(UserOverviewDto overviewDto) {