This commit is contained in:
crusader 2018-06-06 02:33:32 +09:00
parent 46d867991c
commit efb8c949dc
9 changed files with 131 additions and 9 deletions

View File

@ -50,7 +50,7 @@
<dependency>
<groupId>com.loafle.overflow</groupId>
<artifactId>commons-java</artifactId>
<version>1.0.12-SNAPSHOT</version>
<version>1.0.13-SNAPSHOT</version>
</dependency>
<dependency>

View File

@ -4,6 +4,8 @@ import com.loafle.overflow.model.domain.Domain;
import com.loafle.overflow.model.domain.DomainMember;
import com.loafle.overflow.model.member.Member;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
@ -16,7 +18,9 @@ public interface DomainMemberDAO extends JpaRepository<DomainMember, Long> {
DomainMember findByMemberEmail(String memberEmail);
Domain findDomainByMemberId(Long memberId);
@Query("SELECT dm.domain from DomainMember dm where dm.member.email = :memberEmail")
Domain findDomainByMemberEmail(@Param("memberEmail") String memberEmail);
List<Member> findAllMemberByDomainId(Long domainID);
@Query("SELECT dm.member from DomainMember dm where dm.domain.id = :domainId")
List<Member> findAllMemberByDomainId(@Param("domainId") Long domainId);
}

View File

@ -24,8 +24,8 @@ public class CentralDomainMemberService implements DomainMemberService {
this.domainMemberDAO.save(domainMember);
}
public Domain readDomainByMemberID(Long memberID) {
return this.domainMemberDAO.findDomainByMemberId(memberID);
public Domain readDomainByMemberEmail(String memberEmail) {
return this.domainMemberDAO.findDomainByMemberEmail(memberEmail);
}
public DomainMember readByMemberEmail(String email) {

View File

@ -3,6 +3,8 @@ package com.loafle.overflow.central.module.meta.dao;
import com.loafle.overflow.model.meta.MetaSensorDisplayMapping;
import com.loafle.overflow.model.meta.MetaSensorItemKey;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
@ -12,5 +14,7 @@ import java.util.List;
*/
@Repository
public interface MetaSensorDisplayMappingDAO extends JpaRepository<MetaSensorDisplayMapping, Short> {
public List<MetaSensorItemKey> findAllMetaSensorItemKeyByMetaSensorDisplayItemId(Long metaSensorDisplayItemId);
@Query("SELECT m.metaSensorItemKey from MetaSensorDisplayMapping m where m.metaSensorDisplayItem.id = :metaSensorDisplayItemId")
public List<MetaSensorItemKey> findAllMetaSensorItemKeyByMetaSensorDisplayItemId(@Param("metaSensorDisplayItemId") Long metaSensorDisplayItemId);
}

View File

@ -4,6 +4,8 @@ import com.loafle.overflow.model.meta.MetaSensorItemKey;
import com.loafle.overflow.model.sensor.SensorItemDependency;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
@ -14,5 +16,6 @@ import java.util.List;
@Repository
public interface SensorItemDependencyDAO extends JpaRepository<SensorItemDependency, Long> {
List<MetaSensorItemKey> findAllByMetaSensorDisplayItemId(Long metaSensorDisplayItemId);
@Query("SELECT s.metaSensorItemKey from SensorItemDependency s where s.metaSensorDisplayItem.id = :metaSensorDisplayItemId")
List<MetaSensorItemKey> findAllMetaSensorItemKeyByMetaSensorDisplayItemId(@Param("metaSensorDisplayItemId") Long metaSensorDisplayItemId);
}

View File

@ -30,7 +30,7 @@ public class CentralSensorItemDependencyService implements SensorItemDependencyS
public List<MetaSensorItemKey> readAllMetaSensorItemKeyByMetaSensorDisplayItemID(Long metaSensorDisplayItemID)
throws OverflowException {
return this.sensorItemDependencyDAO.findAllByMetaSensorDisplayItemId(metaSensorDisplayItemID);
return this.sensorItemDependencyDAO.findAllMetaSensorItemKeyByMetaSensorDisplayItemId(metaSensorDisplayItemID);
}
public Map<String, List<MetaSensorItemKey>> readAllMapByMetaSensorDisplayItems(
@ -40,7 +40,7 @@ public class CentralSensorItemDependencyService implements SensorItemDependencyS
for (MetaSensorDisplayItem displayItem : metaSensorDisplayItems) {
List<MetaSensorItemKey> itemKeys = this.sensorItemDependencyDAO
.findAllByMetaSensorDisplayItemId(displayItem.getId());
.findAllMetaSensorItemKeyByMetaSensorDisplayItemId(displayItem.getId());
map.put(displayItem.getKey(), itemKeys);
}

View File

@ -0,0 +1,42 @@
package com.loafle.overflow.central.module.domain.dao;
import static org.junit.Assert.assertNotNull;
import java.util.List;
import com.loafle.overflow.central.spring.AppConfigTest;
import com.loafle.overflow.model.domain.Domain;
import com.loafle.overflow.model.member.Member;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* Created by snoop on 17. 9. 14.
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {AppConfigTest.class})
public class DomainMemberDAOTest {
@Autowired
private DomainMemberDAO domainMemberDAO;
@Test
public void findDomainByMemberEmail() throws Exception {
Domain domain = this.domainMemberDAO.findDomainByMemberEmail("overflow@loafle.com");
assertNotNull(domain);
}
@Test
public void findAllMemberByDomainId() throws Exception {
List<Member> members = this.domainMemberDAO.findAllMemberByDomainId(Long.valueOf(1));
assertNotNull(members);
}
}

View File

@ -0,0 +1,34 @@
package com.loafle.overflow.central.module.meta.dao;
import static org.junit.Assert.assertNotNull;
import java.util.List;
import com.loafle.overflow.central.spring.AppConfigTest;
import com.loafle.overflow.model.meta.MetaSensorItemKey;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* Created by snoop on 17. 9. 14.
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {AppConfigTest.class})
public class MetaSensorDisplayMappingDAOTest {
@Autowired
private MetaSensorDisplayMappingDAO metaSensorDisplayMappingDAO;
@Test
public void findAllMetaSensorItemKeyByMetaSensorDisplayItemId() throws Exception {
List<MetaSensorItemKey> metaSensorItemKeys = this.metaSensorDisplayMappingDAO.findAllMetaSensorItemKeyByMetaSensorDisplayItemId(Long.valueOf(1));
assertNotNull(metaSensorItemKeys);
}
}

View File

@ -0,0 +1,35 @@
package com.loafle.overflow.central.module.sensor.dao;
import static org.junit.Assert.assertNotNull;
import java.util.List;
import com.loafle.overflow.central.spring.AppConfigTest;
import com.loafle.overflow.model.meta.MetaSensorItemKey;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* Created by snoop on 17. 9. 14.
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = { AppConfigTest.class })
public class SensorItemDependencyDAOTest {
@Autowired
private SensorItemDependencyDAO sensorItemDependencyDAO;
@Test
public void findAllMetaSensorItemKeyByMetaSensorDisplayItemId() throws Exception {
List<MetaSensorItemKey> metaSensorItemKeys = this.sensorItemDependencyDAO
.findAllMetaSensorItemKeyByMetaSensorDisplayItemId(Long.valueOf(1));
assertNotNull(metaSensorItemKeys);
}
}