From 4f9ee4cb57fbc06d9d75f92b7d20da804e276300 Mon Sep 17 00:00:00 2001 From: pahnjy Date: Fri, 10 Feb 2017 11:03:00 +0900 Subject: [PATCH] =?UTF-8?q?Service,ServiceModel=20=EA=B2=80=EC=83=89=20API?= =?UTF-8?q?=20=EC=88=98=EC=A0=95=20#373?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../icbms/so/service/logic/ServiceLogicImpl.java | 14 +++++++++++++- .../service/store/mongo/ServiceStoreMongoImpl.java | 3 ++- .../store/mongo/ServiceModelStoreMongoImpl.java | 3 ++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/so-service/src/main/java/com/pineone/icbms/so/service/logic/ServiceLogicImpl.java b/so-service/src/main/java/com/pineone/icbms/so/service/logic/ServiceLogicImpl.java index a5cfafb4..996c86bf 100644 --- a/so-service/src/main/java/com/pineone/icbms/so/service/logic/ServiceLogicImpl.java +++ b/so-service/src/main/java/com/pineone/icbms/so/service/logic/ServiceLogicImpl.java @@ -14,6 +14,7 @@ import com.pineone.icbms.so.service.store.ServiceStore; import com.pineone.icbms.so.util.TimeStamp; import com.pineone.icbms.so.util.conversion.DataConversion; +import com.pineone.icbms.so.util.conversion.UUIDConverter; import com.pineone.icbms.so.util.exception.BadRequestException; import com.pineone.icbms.so.util.priority.Priority; import com.pineone.icbms.so.util.session.DefaultSession; @@ -25,6 +26,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.UUID; /** @@ -88,7 +90,17 @@ public List retrieveStatusList(ConceptService conceptService) { @Override //NOTE: Service 등록정보를 수신받고 SO DB에 저장 public String registerService(Service service) { - logger.debug("Service = " + service.toString()); + if(service == null){ + logger.warn("You can not register a service. service is Null"); + return null; + } + if(service.getId() == null){ + service.setId("si-make-"+ UUIDConverter.shortUUID(UUID.randomUUID().toString().toCharArray())); + } + long time = System.currentTimeMillis(); + service.setCreateTime(time); + service.setModifiedTime(time); + logger.debug("service = " + service); ResponseMessage responseMessage = ResponseMessage.newResponseMessage(); String serviceMessageStr = responseMessage.serviceResultMessage(service); serviceStore.createService(service); diff --git a/so-service/src/main/java/com/pineone/icbms/so/service/store/mongo/ServiceStoreMongoImpl.java b/so-service/src/main/java/com/pineone/icbms/so/service/store/mongo/ServiceStoreMongoImpl.java index 2567d9c1..fb307916 100644 --- a/so-service/src/main/java/com/pineone/icbms/so/service/store/mongo/ServiceStoreMongoImpl.java +++ b/so-service/src/main/java/com/pineone/icbms/so/service/store/mongo/ServiceStoreMongoImpl.java @@ -5,6 +5,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Sort; import org.springframework.stereotype.Repository; import java.util.ArrayList; @@ -29,7 +30,7 @@ public void createService(Service service) { //NOTE: Service List 조회 @Override public List retrieveServiceList() { - List serviceDataObjectList = serviceRepository.findAll(); + List serviceDataObjectList = serviceRepository.findAll(new Sort(Sort.Direction.DESC,"createTime")); List serviceList = new ArrayList<>(); for (ServiceDataObject serviceDataObject : serviceDataObjectList){ serviceList.add(dataObjectToService(serviceDataObject)); diff --git a/so-servicemodel/src/main/java/com/pineone/icbms/so/servicemodel/store/mongo/ServiceModelStoreMongoImpl.java b/so-servicemodel/src/main/java/com/pineone/icbms/so/servicemodel/store/mongo/ServiceModelStoreMongoImpl.java index cd758faf..b4306c5a 100644 --- a/so-servicemodel/src/main/java/com/pineone/icbms/so/servicemodel/store/mongo/ServiceModelStoreMongoImpl.java +++ b/so-servicemodel/src/main/java/com/pineone/icbms/so/servicemodel/store/mongo/ServiceModelStoreMongoImpl.java @@ -5,6 +5,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Sort; import org.springframework.stereotype.Repository; import java.util.ArrayList; @@ -31,7 +32,7 @@ public void createServiceModel(ServiceModel serviceModel) { //NOTE: SM 리스트 조회 @Override public List retrieveServiceModelList() { - List serviceModelDataObjectList = serviceModelRepository.findAll(); + List serviceModelDataObjectList = serviceModelRepository.findAll(new Sort(Sort.Direction.DESC,"createTime")); List serviceModelList = new ArrayList<>(); for(ServiceModelDataObject serviceModelDataObject : serviceModelDataObjectList){ serviceModelList.add(dataObjectToServiceModel(serviceModelDataObject));