From 49eed31587cd440b17ccc1d734dc77a27100798f Mon Sep 17 00:00:00 2001 From: lishengzhao Date: Mon, 25 May 2015 12:04:57 +0800 Subject: [PATCH] 00018 client_details list --- .../java/cc/wdcy/domain/oauth/OauthRepository.java | 3 +++ src/main/java/cc/wdcy/service/OauthService.java | 2 ++ .../java/cc/wdcy/service/impl/OauthServiceImpl.java | 5 +++++ .../wdcy/web/controller/ClientDetailsController.java | 11 +++++++++++ .../cc/wdcy/infrastructure/mybatis/OauthMapper.xml | 5 +++++ .../mybatis/OauthRepositoryMyBatisTest.java | 5 +++++ 6 files changed, 31 insertions(+) diff --git a/src/main/java/cc/wdcy/domain/oauth/OauthRepository.java b/src/main/java/cc/wdcy/domain/oauth/OauthRepository.java index ac83f30..8f4a844 100644 --- a/src/main/java/cc/wdcy/domain/oauth/OauthRepository.java +++ b/src/main/java/cc/wdcy/domain/oauth/OauthRepository.java @@ -1,6 +1,7 @@ package cc.wdcy.domain.oauth; import cc.wdcy.domain.shared.Repository; +import org.apache.ibatis.annotations.Param; import java.util.List; @@ -12,4 +13,6 @@ public interface OauthRepository extends Repository { OauthClientDetails findOauthClientDetails(String clientId); List findAllOauthClientDetails(); + + void updateOauthClientDetailsArchive(@Param("clientId") String clientId, @Param("archive") boolean archive); } \ No newline at end of file diff --git a/src/main/java/cc/wdcy/service/OauthService.java b/src/main/java/cc/wdcy/service/OauthService.java index 677b306..cb25da1 100644 --- a/src/main/java/cc/wdcy/service/OauthService.java +++ b/src/main/java/cc/wdcy/service/OauthService.java @@ -14,4 +14,6 @@ public interface OauthService { OauthClientDetails loadOauthClientDetails(String clientId); List loadAllOauthClientDetailsDtos(); + + void archiveOauthClientDetails(String clientId); } \ No newline at end of file diff --git a/src/main/java/cc/wdcy/service/impl/OauthServiceImpl.java b/src/main/java/cc/wdcy/service/impl/OauthServiceImpl.java index 7b89270..93ede50 100644 --- a/src/main/java/cc/wdcy/service/impl/OauthServiceImpl.java +++ b/src/main/java/cc/wdcy/service/impl/OauthServiceImpl.java @@ -28,4 +28,9 @@ public class OauthServiceImpl implements OauthService { List clientDetailses = oauthRepository.findAllOauthClientDetails(); return OauthClientDetailsDto.toDtos(clientDetailses); } + + @Override + public void archiveOauthClientDetails(String clientId) { + oauthRepository.updateOauthClientDetailsArchive(clientId, true); + } } \ No newline at end of file diff --git a/src/main/java/cc/wdcy/web/controller/ClientDetailsController.java b/src/main/java/cc/wdcy/web/controller/ClientDetailsController.java index dcd3389..16ac70f 100644 --- a/src/main/java/cc/wdcy/web/controller/ClientDetailsController.java +++ b/src/main/java/cc/wdcy/web/controller/ClientDetailsController.java @@ -5,6 +5,7 @@ import cc.wdcy.service.OauthService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import java.util.List; @@ -30,4 +31,14 @@ public class ClientDetailsController { } + /* + * Logic delete + * */ + @RequestMapping("archive_client/{clientId}") + public String archiveClient(@PathVariable("clientId") String clientId) { + oauthService.archiveOauthClientDetails(clientId); + return "redirect:../client_details"; + } + + } \ No newline at end of file diff --git a/src/main/resources/cc/wdcy/infrastructure/mybatis/OauthMapper.xml b/src/main/resources/cc/wdcy/infrastructure/mybatis/OauthMapper.xml index 2df6601..c6da330 100644 --- a/src/main/resources/cc/wdcy/infrastructure/mybatis/OauthMapper.xml +++ b/src/main/resources/cc/wdcy/infrastructure/mybatis/OauthMapper.xml @@ -33,5 +33,10 @@ select * from oauth_client_details + + update oauth_client_details set archived = #{archive} + where client_id = #{clientId} + + \ No newline at end of file diff --git a/src/test/java/cc/wdcy/infrastructure/mybatis/OauthRepositoryMyBatisTest.java b/src/test/java/cc/wdcy/infrastructure/mybatis/OauthRepositoryMyBatisTest.java index 1830c3a..4c1659a 100644 --- a/src/test/java/cc/wdcy/infrastructure/mybatis/OauthRepositoryMyBatisTest.java +++ b/src/test/java/cc/wdcy/infrastructure/mybatis/OauthRepositoryMyBatisTest.java @@ -34,4 +34,9 @@ public class OauthRepositoryMyBatisTest extends AbstractRepositoryTest { assertTrue(allOauthClientDetails.isEmpty()); } + @Test + public void updateOauthClientDetailsArchive() { + oauthRepositoryMyBatis.updateOauthClientDetailsArchive("ddooelddd", true); + } + } \ No newline at end of file