Commit 5593b86b authored by Vu Duy Anh's avatar Vu Duy Anh

anhvd commit

parents f6139454 00b43f0b
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="Spring" name="Spring">
<configuration />
</facet>
<facet type="web" name="Web">
<configuration>
<webroots />
<sourceRoots>
<root url="file://$MODULE_DIR$/src/main/java" />
<root url="file://$MODULE_DIR$/src/main/resources" />
</sourceRoots>
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://$USER_HOME$/Downloads/ojdbc6-11.2.0.3.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="library" name="Maven: org.modelmapper:modelmapper:2.3.2" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-actuator:2.0.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter:2.0.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-logging:2.0.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: ch.qos.logback:logback-classic:1.2.3" level="project" />
<orderEntry type="library" name="Maven: ch.qos.logback:logback-core:1.2.3" level="project" />
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-to-slf4j:2.10.0" level="project" />
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-api:2.10.0" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:jul-to-slf4j:1.7.25" level="project" />
<orderEntry type="library" name="Maven: javax.annotation:javax.annotation-api:1.3.2" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: org.yaml:snakeyaml:1.19" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-actuator-autoconfigure:2.0.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-actuator:2.0.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.9.7" level="project" />
<orderEntry type="library" name="Maven: io.micrometer:micrometer-core:1.0.7" level="project" />
<orderEntry type="library" name="Maven: org.hdrhistogram:HdrHistogram:2.1.10" level="project" />
<orderEntry type="library" name="Maven: org.latencyutils:LatencyUtils:2.0.3" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-aop:2.0.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-aop:5.0.10.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-beans:5.0.10.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.aspectj:aspectjweaver:1.8.13" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-batch:2.0.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-jdbc:2.0.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: com.zaxxer:HikariCP:2.7.9" level="project" />
<orderEntry type="library" name="Maven: org.springframework.batch:spring-batch-core:4.0.1.RELEASE" level="project" />
<orderEntry type="library" name="Maven: javax.batch:javax.batch-api:1.0" level="project" />
<orderEntry type="library" name="Maven: org.codehaus.jettison:jettison:1.2" level="project" />
<orderEntry type="library" name="Maven: org.springframework.batch:spring-batch-infrastructure:4.0.1.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-data-jpa:2.0.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: javax.transaction:javax.transaction-api:1.2" level="project" />
<orderEntry type="library" name="Maven: org.springframework.data:spring-data-jpa:2.0.11.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.data:spring-data-commons:2.0.11.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-orm:5.0.10.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-aspects:5.0.10.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-data-redis:2.0.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.data:spring-data-redis:2.0.11.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.data:spring-data-keyvalue:2.0.11.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-context-support:5.0.10.RELEASE" level="project" />
<orderEntry type="library" name="Maven: io.lettuce:lettuce-core:5.0.5.RELEASE" level="project" />
<orderEntry type="library" name="Maven: io.projectreactor:reactor-core:3.1.10.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.reactivestreams:reactive-streams:1.0.2" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-common:4.1.29.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-transport:4.1.29.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-buffer:4.1.29.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-resolver:4.1.29.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-handler:4.1.29.Final" level="project" />
<orderEntry type="library" name="Maven: io.netty:netty-codec:4.1.29.Final" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-security:2.0.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.security:spring-security-config:5.0.9.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.security:spring-security-web:5.0.9.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-expression:5.0.10.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-validation:2.0.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-el:8.5.34" level="project" />
<orderEntry type="library" name="Maven: org.hibernate.validator:hibernate-validator:6.0.13.Final" level="project" />
<orderEntry type="library" name="Maven: javax.validation:validation-api:2.0.1.Final" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-web:2.0.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-json:2.0.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.9.7" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.module:jackson-module-parameter-names:2.9.7" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-tomcat:2.0.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-core:8.5.34" level="project" />
<orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-websocket:8.5.34" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-web:5.0.10.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-webmvc:5.0.10.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-starter-sleuth:2.0.2.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-starter:2.0.2.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-context:2.0.2.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.security:spring-security-crypto:5.0.9.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-commons:2.0.2.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.security:spring-security-rsa:1.0.7.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.bouncycastle:bcpkix-jdk15on:1.60" level="project" />
<orderEntry type="library" name="Maven: org.bouncycastle:bcprov-jdk15on:1.60" level="project" />
<orderEntry type="library" name="Maven: org.springframework.cloud:spring-cloud-sleuth-core:2.0.2.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.aspectj:aspectjrt:1.8.13" level="project" />
<orderEntry type="library" name="Maven: io.zipkin.brave:brave:5.4.3" level="project" />
<orderEntry type="library" name="Maven: io.zipkin.zipkin2:zipkin:2.11.7" level="project" />
<orderEntry type="library" name="Maven: io.zipkin.reporter2:zipkin-reporter:2.7.10" level="project" />
<orderEntry type="library" name="Maven: io.zipkin.brave:brave-context-log4j2:5.4.3" level="project" />
<orderEntry type="library" name="Maven: io.zipkin.brave:brave-instrumentation-spring-web:5.4.3" level="project" />
<orderEntry type="library" name="Maven: io.zipkin.brave:brave-instrumentation-http:5.4.3" level="project" />
<orderEntry type="library" name="Maven: io.zipkin.brave:brave-instrumentation-spring-rabbit:5.4.3" level="project" />
<orderEntry type="library" name="Maven: io.zipkin.brave:brave-instrumentation-kafka-clients:5.4.3" level="project" />
<orderEntry type="library" name="Maven: io.zipkin.brave:brave-instrumentation-httpclient:5.4.3" level="project" />
<orderEntry type="library" name="Maven: io.zipkin.brave:brave-instrumentation-httpasyncclient:5.4.3" level="project" />
<orderEntry type="library" name="Maven: io.zipkin.brave:brave-instrumentation-spring-webmvc:5.4.3" level="project" />
<orderEntry type="library" name="Maven: io.zipkin.brave:brave-instrumentation-servlet:5.4.3" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-web-services:2.0.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-oxm:5.0.10.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.ws:spring-ws-core:3.0.4.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.ws:spring-xml:3.0.4.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-websocket:2.0.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-messaging:5.0.10.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-websocket:5.0.10.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.apache.kafka:kafka-streams:1.0.2" level="project" />
<orderEntry type="library" name="Maven: org.apache.kafka:kafka-clients:1.0.2" level="project" />
<orderEntry type="library" name="Maven: org.lz4:lz4-java:1.4" level="project" />
<orderEntry type="library" name="Maven: org.xerial.snappy:snappy-java:1.1.4" level="project" />
<orderEntry type="library" name="Maven: org.apache.kafka:connect-json:1.0.2" level="project" />
<orderEntry type="library" name="Maven: org.apache.kafka:connect-api:1.0.2" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.25" level="project" />
<orderEntry type="library" name="Maven: org.rocksdb:rocksdbjni:5.7.3" level="project" />
<orderEntry type="library" name="Maven: org.springframework.kafka:spring-kafka:2.1.10.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-context:5.0.10.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-tx:5.0.10.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.retry:spring-retry:1.2.2.RELEASE" level="project" />
<orderEntry type="module-library">
<library name="Maven: com.oracle:ojdbc7:1.0">
<CLASSES>
<root url="jar://$MODULE_DIR$/lib/ojdbc7.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="library" name="Maven: org.hibernate:hibernate-entitymanager:5.1.0.Final" level="project" />
<orderEntry type="library" name="Maven: org.jboss.logging:jboss-logging:3.3.2.Final" level="project" />
<orderEntry type="library" name="Maven: dom4j:dom4j:1.6.1" level="project" />
<orderEntry type="library" name="Maven: org.hibernate.common:hibernate-commons-annotations:5.0.1.Final" level="project" />
<orderEntry type="library" name="Maven: org.hibernate.javax.persistence:hibernate-jpa-2.1-api:1.0.2.Final" level="project" />
<orderEntry type="library" name="Maven: org.javassist:javassist:3.20.0-GA" level="project" />
<orderEntry type="library" name="Maven: org.apache.geronimo.specs:geronimo-jta_1.1_spec:1.1.1" level="project" />
<orderEntry type="library" name="Maven: org.hibernate:hibernate-core:5.1.0.Final" level="project" />
<orderEntry type="library" name="Maven: antlr:antlr:2.7.7" level="project" />
<orderEntry type="library" name="Maven: org.jboss:jandex:2.0.0.Final" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml:classmate:1.3.4" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: org.springframework.boot:spring-boot-devtools:2.0.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot:2.0.6.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-autoconfigure:2.0.6.RELEASE" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: com.h2database:h2:1.4.197" level="project" />
<orderEntry type="library" name="Maven: org.projectlombok:lombok:1.16.22" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-starter-test:2.0.6.RELEASE" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test:2.0.6.RELEASE" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test-autoconfigure:2.0.6.RELEASE" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: com.jayway.jsonpath:json-path:2.4.0" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: net.minidev:json-smart:2.3" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: net.minidev:accessors-smart:1.2" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.ow2.asm:asm:5.0.4" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.12" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.assertj:assertj-core:3.9.1" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.mockito:mockito-core:2.15.0" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: net.bytebuddy:byte-buddy:1.7.11" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: net.bytebuddy:byte-buddy-agent:1.7.11" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.objenesis:objenesis:2.6" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-library:1.3" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.skyscreamer:jsonassert:1.5.0" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: com.vaadin.external.google:android-json:0.0.20131108.vaadin1" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-core:5.0.10.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-jcl:5.0.10.RELEASE" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.springframework:spring-test:5.0.10.RELEASE" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.xmlunit:xmlunit-core:2.5.1" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.batch:spring-batch-test:4.0.1.RELEASE" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: commons-collections:commons-collections:3.2.2" level="project" />
<orderEntry type="library" name="Maven: commons-io:commons-io:2.6" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-jdbc:5.0.10.RELEASE" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.kafka:spring-kafka-test:2.1.10.RELEASE" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.apache.kafka:kafka-clients:test:1.0.2" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.apache.kafka:kafka_2.11:1.0.2" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: net.sf.jopt-simple:jopt-simple:5.0.4" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: com.yammer.metrics:metrics-core:2.2.0" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.scala-lang:scala-library:2.11.12" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: com.101tec:zkclient:0.10" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.apache.zookeeper:zookeeper:3.4.10" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.apache.kafka:kafka_2.11:test:1.0.2" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.restdocs:spring-restdocs-mockmvc:2.0.2.RELEASE" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: javax.servlet:javax.servlet-api:3.1.0" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.restdocs:spring-restdocs-core:2.0.2.RELEASE" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.security:spring-security-test:5.0.9.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework.security:spring-security-core:5.0.9.RELEASE" level="project" />
<orderEntry type="library" name="Maven: log4j:log4j:1.2.17" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.9.8" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.9.8" level="project" />
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.9.8" level="project" />
<orderEntry type="library" name="Maven: joda-time:joda-time:2.9.9" level="project" />
<orderEntry type="library" name="Maven: org.modelmapper:modelmapper:2.3.2" level="project" />
</component>
</module>
\ No newline at end of file
...@@ -13,20 +13,20 @@ public interface CustomerListMappingRepository extends JpaRepository<CustomerLis ...@@ -13,20 +13,20 @@ public interface CustomerListMappingRepository extends JpaRepository<CustomerLis
// ----------- customer ------------ // // ----------- customer ------------ //
@Modifying @Modifying
@Query("delete from CustomerListMapping c where c.customerId=:p_customer_id and c.customerListId=:p_customer_list_id") @Query("delete from CustomerListMapping c where c.customerId=:p_customer_id and c.customerListId=:p_customer_list_id and c.companySiteId=:p_company_site_id")
int deleteMappingByCustomerId(@Param("p_customer_id") Long p_customer_id, @Param("p_customer_list_id") Long p_customer_list_id); int deleteMappingByCustomerId(@Param("p_customer_id") Long p_customer_id, @Param("p_customer_list_id") Long p_customer_list_id, @Param("p_company_site_id") Long p_company_site_id);
@Modifying @Modifying
@Query("delete from CustomerListMapping c where c.customerId in (:p_id) and c.customerListId =:p_customer_list_id") @Query("delete from CustomerListMapping c where c.customerId in (:p_ids) and c.customerListId =:p_customer_list_id and c.companySiteId=:p_company_site_id")
int deleteMappingByCustomerIds(@Param("p_id") List<Long> p_id, @Param("p_customer_list_id") Long p_customer_list_id); int deleteMappingByCustomerIds(@Param("p_ids") List<Long> p_ids, @Param("p_customer_list_id") Long p_customer_list_id, @Param("p_company_site_id") Long p_company_site_id);
// ----------- customer list --------------- // // ----------- customer list --------------- //
@Modifying @Modifying
@Query("delete from CustomerListMapping c where c.customerListId=:p_customerListId") @Query("delete from CustomerListMapping c where c.customerListId=:p_customer_list_id and c.companySiteId=:p_company_site_id")
int deleteMappingByCustomerListId(@Param("p_customerListId") Long p_customerListId); int deleteMappingByCustomerListId(@Param("p_customer_list_id") Long p_customer_list_id, @Param("p_company_site_id") Long p_company_site_id);
@Modifying @Modifying
@Query("delete from CustomerListMapping c where c.customerListId in (:p_ids)") @Query("delete from CustomerListMapping c where c.customerListId in (:p_ids) and c.companySiteId=:p_company_site_id")
int deleteMappingByCustomerListIds(@Param("p_ids") List<Long> p_ids); int deleteMappingByCustomerListIds(@Param("p_ids") List<Long> p_ids, @Param("p_company_site_id") Long p_company_site_id);
} }
...@@ -10,15 +10,15 @@ import java.util.List; ...@@ -10,15 +10,15 @@ import java.util.List;
public interface CustomerListRepository extends JpaRepository<CustomerList, Long> { public interface CustomerListRepository extends JpaRepository<CustomerList, Long> {
CustomerList findCustomerListByCustomerListId(long customerListId); CustomerList findByCustomerListIdAndCompanySiteId(long customerListId, long companySiteId);
CustomerList findByCustomerListCode(String customerListCode); CustomerList findByCustomerListCode(String customerListCode);
@Modifying @Modifying
@Query("update CustomerList c set c.status = 0 where c.customerListId=:p_customerListId") @Query("update CustomerList c set c.status = 0 where c.customerListId=:p_customer_list_id and c.companySiteId=:p_company_site_id")
int deleteCustomerList(@Param("p_customerListId") Long p_customerListId); int deleteCustomerList(@Param("p_customer_list_id") Long p_customer_list_id, @Param("p_company_site_id") Long p_company_site_id);
@Modifying @Modifying
@Query("update CustomerList c set c.status = 0 where c.customerListId in (:p_ids)") @Query("update CustomerList c set c.status = 0 where c.customerListId in (:p_ids) and c.companySiteId=:p_company_site_id")
int deleteCustomerListIds(@Param("p_ids") List<Long> p_ids); int deleteCustomerListIds(@Param("p_ids") List<Long> p_ids, @Param("p_company_site_id") Long p_company_site_id);
} }
...@@ -3,16 +3,14 @@ package com.viettel.campaign.service; ...@@ -3,16 +3,14 @@ package com.viettel.campaign.service;
import com.viettel.campaign.web.dto.CustomerDTO; import com.viettel.campaign.web.dto.CustomerDTO;
import com.viettel.campaign.web.dto.CustomerListDTO; import com.viettel.campaign.web.dto.CustomerListDTO;
import com.viettel.campaign.web.dto.ResultDTO; import com.viettel.campaign.web.dto.ResultDTO;
import com.viettel.campaign.web.dto.request_dto.CampaignCustomerRequestDTO; import com.viettel.campaign.web.dto.request_dto.SearchCustomerRequestDTO;
import com.viettel.campaign.web.dto.request_dto.DeleteCustomerRequestDTO; import com.viettel.campaign.web.dto.request_dto.CustomerRequestDTO;
import java.util.Date;
import java.util.List;
import java.util.Map; import java.util.Map;
public interface CustomerService { public interface CustomerService {
Map listAllCustomer(int page, int pageSize, String sort); ResultDTO listAllCustomer(int page, int pageSize, String sort, long customerListId, long companySiteId);
ResultDTO getCustomerId(Long customerId); ResultDTO getCustomerId(Long customerId);
...@@ -20,9 +18,9 @@ public interface CustomerService { ...@@ -20,9 +18,9 @@ public interface CustomerService {
ResultDTO createCustomer(CustomerDTO customerDTO); ResultDTO createCustomer(CustomerDTO customerDTO);
ResultDTO deleteCustomer(DeleteCustomerRequestDTO deleteCustomerRequestDTO); ResultDTO deleteCustomer(CustomerRequestDTO customerRequestDTO);
ResultDTO deleteIds(DeleteCustomerRequestDTO deleteCustomerRequestDTO); ResultDTO deleteIds(CustomerRequestDTO customerRequestDTO);
// ------------ customer list ------------ // // ------------ customer list ------------ //
...@@ -34,7 +32,9 @@ public interface CustomerService { ...@@ -34,7 +32,9 @@ public interface CustomerService {
ResultDTO deleteCustomerList(CustomerListDTO customerListDTO); ResultDTO deleteCustomerList(CustomerListDTO customerListDTO);
ResultDTO deleteCustomerListIds(List<Long> ids); ResultDTO deleteCustomerListIds(CustomerRequestDTO customerRequestDTO);
ResultDTO searchCustomerList(SearchCustomerRequestDTO searchCustomerRequestDTO);
ResultDTO searchCustomerList(CampaignCustomerRequestDTO campaignCustomerRequestDTO); ResultDTO searchCustomerList(CampaignCustomerRequestDTO campaignCustomerRequestDTO);
......
...@@ -8,14 +8,15 @@ import com.viettel.campaign.service.CustomerService; ...@@ -8,14 +8,15 @@ import com.viettel.campaign.service.CustomerService;
import com.viettel.campaign.utils.Constants; import com.viettel.campaign.utils.Constants;
import com.viettel.campaign.utils.HibernateUtil; import com.viettel.campaign.utils.HibernateUtil;
import com.viettel.campaign.utils.SQLBuilder; import com.viettel.campaign.utils.SQLBuilder;
import com.viettel.campaign.web.dto.CustomerCustomDTO;
import com.viettel.campaign.web.dto.CustomerDTO; import com.viettel.campaign.web.dto.CustomerDTO;
import com.viettel.campaign.web.dto.CustomerListDTO; import com.viettel.campaign.web.dto.CustomerListDTO;
import com.viettel.campaign.web.dto.ResultDTO; import com.viettel.campaign.web.dto.ResultDTO;
import com.viettel.campaign.mapper.CustomerMapper; import com.viettel.campaign.mapper.CustomerMapper;
import com.viettel.campaign.model.Customer; import com.viettel.campaign.model.Customer;
import com.viettel.campaign.utils.DataUtil; import com.viettel.campaign.utils.DataUtil;
import com.viettel.campaign.web.dto.request_dto.CampaignCustomerRequestDTO; import com.viettel.campaign.web.dto.request_dto.SearchCustomerRequestDTO;
import com.viettel.campaign.web.dto.request_dto.DeleteCustomerRequestDTO; import com.viettel.campaign.web.dto.request_dto.CustomerRequestDTO;
import org.hibernate.SQLQuery; import org.hibernate.SQLQuery;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.SessionFactory; import org.hibernate.SessionFactory;
...@@ -55,17 +56,76 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -55,17 +56,76 @@ public class CustomerServiceImpl implements CustomerService {
CustomerListMappingRepository customerListMappingRepository; CustomerListMappingRepository customerListMappingRepository;
@Override @Override
public Map listAllCustomer(int page, int pageSize, String sort) { public ResultDTO listAllCustomer(int page, int pageSize, String sort, long customerListId, long companySiteId) {
Map result = new HashMap(); // Map result = new HashMap();
List<Customer> lst = new ArrayList<>(); // List<Customer> lst = new ArrayList<>();
//
// Pageable pageable = PageRequest.of(page, pageSize, Sort.by(sort));
// Page<Customer> pc = customerRepository.findAll(pageable);
//
// result.put("totalItem", pc.getTotalElements());
// result.put("customers", pc.iterator());
//
// return result;
ResultDTO resultDTO = new ResultDTO();
SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
Pageable pageable = PageRequest.of(page, pageSize, Sort.by(sort)); Session session = sessionFactory.openSession();
Page<Customer> pc = customerRepository.findAll(pageable); session.beginTransaction();
result.put("totalItem", pc.getTotalElements()); if (DataUtil.isNullOrZero(companySiteId)) {
result.put("customers", pc.iterator()); resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
return resultDTO;
}
return result; try {
StringBuilder sqlStrBuilder = new StringBuilder();
sqlStrBuilder.append(SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_MNG, "campaign-customer-detail-by-params"));
SQLQuery query = session.createSQLQuery(sqlStrBuilder.toString());
query.setParameter("p_company_site_id", companySiteId);
query.setParameter("p_customer_list_id", customerListId);
query.addScalar("customerListMappingId", new LongType());
query.addScalar("companySiteId", new LongType());
query.addScalar("customerListId", new LongType());
query.addScalar("customerId", new LongType());
query.addScalar("name", new StringType());
query.addScalar("description", new StringType());
query.addScalar("companyName", new StringType());
query.addScalar("customerType", new StringType());
query.addScalar("currentAddress", new StringType());
query.addScalar("mobileNumber", new StringType());
query.addScalar("email", new StringType());
query.setResultTransformer(Transformers.aliasToBean(CustomerCustomDTO.class));
int count = 0;
List<CustomerListDTO> dtoList = query.list();
if (dtoList.size() > 0) {
count = query.list().size();
}
// Pageable pageable = PageRequest.of(page, pageSize, Sort.by(sort));
// if (pageable != null) {
// query.setFirstResult(pageable.getPageNumber() * pageable.getPageSize());
// query.setMaxResults(pageable.getPageSize());
// }
Pageable pageable = PageRequest.of(page, pageSize, Sort.by(sort));
List<CustomerListDTO> data = query.list();
Page<CustomerListDTO> dataPage = new PageImpl<>(data, pageable, count);
resultDTO.setData(dataPage);
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
} catch (Exception e) {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
} finally {
session.close();
}
return resultDTO;
} }
@Override @Override
...@@ -135,14 +195,15 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -135,14 +195,15 @@ public class CustomerServiceImpl implements CustomerService {
return resultDTO; return resultDTO;
} }
@Transactional
@Override @Override
public ResultDTO deleteCustomer(DeleteCustomerRequestDTO deleteCustomerRequestDTO) { public ResultDTO deleteCustomer(CustomerRequestDTO customerRequestDTO) {
ResultDTO resultDTO = new ResultDTO(); ResultDTO resultDTO = new ResultDTO();
try { try {
if (deleteCustomerRequestDTO != null) { if (customerRequestDTO != null) {
// delete // delete
// customerRepository.deleteById(customerDTO.getCustomerId()); // customerRepository.deleteById(customerDTO.getCustomerId());
customerListMappingRepository.deleteMappingByCustomerId(deleteCustomerRequestDTO.getCustomerId(), deleteCustomerRequestDTO.getCustomerListId()); customerListMappingRepository.deleteMappingByCustomerId(customerRequestDTO.getCustomerId(), customerRequestDTO.getCustomerListId(), customerRequestDTO.getCompanySiteId());
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS); resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS); resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
...@@ -159,12 +220,12 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -159,12 +220,12 @@ public class CustomerServiceImpl implements CustomerService {
@Transactional @Transactional
@Override @Override
public ResultDTO deleteIds(DeleteCustomerRequestDTO deleteCustomerRequestDTO) { public ResultDTO deleteIds(CustomerRequestDTO customerRequestDTO) {
ResultDTO resultDTO = new ResultDTO(); ResultDTO resultDTO = new ResultDTO();
try { try {
if (deleteCustomerRequestDTO != null) { if (customerRequestDTO != null) {
// customerRepository.deleteIds(ids); // customerRepository.deleteIds(ids);
customerListMappingRepository.deleteMappingByCustomerIds(deleteCustomerRequestDTO.getCustomerIds(), deleteCustomerRequestDTO.getCustomerListId()); customerListMappingRepository.deleteMappingByCustomerIds(customerRequestDTO.getIds(), customerRequestDTO.getCustomerListId(), customerRequestDTO.getCompanySiteId());
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS); resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS); resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
} else { } else {
...@@ -241,16 +302,22 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -241,16 +302,22 @@ public class CustomerServiceImpl implements CustomerService {
public ResultDTO updateCustomerList(CustomerListDTO customerListDTO) { public ResultDTO updateCustomerList(CustomerListDTO customerListDTO) {
ResultDTO resultDTO = new ResultDTO(); ResultDTO resultDTO = new ResultDTO();
CustomerListMapper customerListMapper = new CustomerListMapper(); CustomerListMapper customerListMapper = new CustomerListMapper();
CustomerList customerList = customerListRepository.findCustomerListByCustomerListId(customerListDTO.getCustomerListId());
try { try {
if (customerListDTO != null) { if (customerListDTO != null) {
// update // update
customerList = customerListMapper.toPersistenceBean(customerListDTO); CustomerList customerList = customerListRepository.findByCustomerListIdAndCompanySiteId(customerListDTO.getCustomerListId(), customerListDTO.getCompanySiteId());
customerListRepository.save(customerList);
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS); if (customerList != null) {
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS); customerList = customerListMapper.toPersistenceBean(customerListDTO);
customerListRepository.save(customerList);
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
} else {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
}
} else { } else {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR); resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR); resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
...@@ -271,9 +338,9 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -271,9 +338,9 @@ public class CustomerServiceImpl implements CustomerService {
// delete // delete
if (DataUtil.isNullOrZero(campaignCustomerListRepository.campaignCount(customerListDTO.getCustomerListId()))) { if (DataUtil.isNullOrZero(campaignCustomerListRepository.campaignCount(customerListDTO.getCustomerListId()))) {
customerListRepository.deleteCustomerList(customerListDTO.getCustomerListId()); customerListRepository.deleteCustomerList(customerListDTO.getCustomerListId(), customerListDTO.getCompanySiteId());
customerListMappingRepository.deleteMappingByCustomerListId(customerListDTO.getCustomerListId()); customerListMappingRepository.deleteMappingByCustomerListId(customerListDTO.getCustomerListId(), customerListDTO.getCompanySiteId());
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS); resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS); resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
...@@ -291,14 +358,14 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -291,14 +358,14 @@ public class CustomerServiceImpl implements CustomerService {
@Transactional @Transactional
@Override @Override
public ResultDTO deleteCustomerListIds(List<Long> ids) { public ResultDTO deleteCustomerListIds(CustomerRequestDTO customerRequestDTO) {
ResultDTO resultDTO = new ResultDTO(); ResultDTO resultDTO = new ResultDTO();
try { try {
if (ids != null) { if (customerRequestDTO != null) {
if (DataUtil.isNullOrZero(campaignCustomerListRepository.campaignIdsCount(ids))) { if (DataUtil.isNullOrZero(campaignCustomerListRepository.campaignIdsCount(customerRequestDTO.getIds()))) {
customerListRepository.deleteCustomerListIds(ids); customerListRepository.deleteCustomerListIds(customerRequestDTO.getIds(), customerRequestDTO.getCompanySiteId());
customerListMappingRepository.deleteMappingByCustomerListIds(ids); customerListMappingRepository.deleteMappingByCustomerListIds(customerRequestDTO.getIds(), customerRequestDTO.getCompanySiteId());
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS); resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS); resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
...@@ -317,14 +384,14 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -317,14 +384,14 @@ public class CustomerServiceImpl implements CustomerService {
} }
@Override @Override
public ResultDTO searchCustomerList(CampaignCustomerRequestDTO campaignCustomerRequestDTO) { public ResultDTO searchCustomerList(SearchCustomerRequestDTO searchCustomerRequestDTO) {
ResultDTO resultDTO = new ResultDTO(); ResultDTO resultDTO = new ResultDTO();
SessionFactory sessionFactory = HibernateUtil.getSessionFactory(); SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
Session session = sessionFactory.openSession(); Session session = sessionFactory.openSession();
session.beginTransaction(); session.beginTransaction();
if (DataUtil.isNullOrEmpty(campaignCustomerRequestDTO.getCompanySiteId())) { if (DataUtil.isNullOrEmpty(searchCustomerRequestDTO.getCompanySiteId())) {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR); resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription(Constants.ApiErrorDesc.ERROR); resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
return resultDTO; return resultDTO;
...@@ -333,33 +400,34 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -333,33 +400,34 @@ public class CustomerServiceImpl implements CustomerService {
try { try {
StringBuilder sqlStrBuilder = new StringBuilder(); StringBuilder sqlStrBuilder = new StringBuilder();
sqlStrBuilder.append(SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_MNG, "search-campaign-customer-by-params")); sqlStrBuilder.append(SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_MNG, "search-campaign-customer-by-params"));
if (DataUtil.isNullOrEmpty(campaignCustomerRequestDTO.getCustomerListCode())) { if (!DataUtil.isNullOrEmpty(searchCustomerRequestDTO.getCustomerListCode())) {
sqlStrBuilder.append(" AND CUSTOMER_LIST_CODE LIKE :p_list_code"); sqlStrBuilder.append(" AND CUSTOMER_LIST_CODE LIKE :p_list_code");
} }
if (DataUtil.isNullOrEmpty(campaignCustomerRequestDTO.getCustomerListName())) { if (!DataUtil.isNullOrEmpty(searchCustomerRequestDTO.getCustomerListName())) {
sqlStrBuilder.append(" AND CUSTOMER_LIST_NAME LIKE :p_list_name"); sqlStrBuilder.append(" AND CUSTOMER_LIST_NAME LIKE :p_list_name");
} }
SQLQuery query = session.createSQLQuery(sqlStrBuilder.toString()); SQLQuery query = session.createSQLQuery(sqlStrBuilder.toString());
query.setParameter("p_date_from", campaignCustomerRequestDTO.getConvertedDateFrom()); query.setParameter("p_date_from", searchCustomerRequestDTO.getConvertedDateFrom());
query.setParameter("p_date_to", campaignCustomerRequestDTO.getConvertedDateTo()); query.setParameter("p_date_to", searchCustomerRequestDTO.getConvertedDateTo());
query.setParameter("p_company_site_id", searchCustomerRequestDTO.getCompanySiteId());
if (!campaignCustomerRequestDTO.getCustomerListCode().equals("undefined")) { if (!DataUtil.isNullOrEmpty(searchCustomerRequestDTO.getCustomerListCode())) {
query.setParameter("p_list_code", "%" + query.setParameter("p_list_code", "%" +
campaignCustomerRequestDTO.getCustomerListCode() searchCustomerRequestDTO.getCustomerListCode()
.replace("\\", "\\\\") .replace("\\", "\\\\")
.replaceAll("%", "\\\\%") .replaceAll("%", "\\%")
.replaceAll("_", "\\\\_") .replaceAll("_", "\\_")
+ "%"); + "%");
} }
if (!campaignCustomerRequestDTO.getCustomerListName().equals("undefined")) { if (!DataUtil.isNullOrEmpty(searchCustomerRequestDTO.getCustomerListName())) {
query.setParameter("p_list_name", "%" + query.setParameter("p_list_name", "%" +
campaignCustomerRequestDTO.getCustomerListName() searchCustomerRequestDTO.getCustomerListName()
.replace("\\", "\\\\") .replace("\\", "\\\\")
.replaceAll("%", "\\\\%") .replaceAll("%", "\\%")
.replaceAll("_", "\\\\_") .replaceAll("_", "\\_")
+ "%"); + "%");
} }
...@@ -381,11 +449,12 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -381,11 +449,12 @@ public class CustomerServiceImpl implements CustomerService {
if (dtoList.size() > 0) { if (dtoList.size() > 0) {
count = query.list().size(); count = query.list().size();
} }
Pageable pageable = SQLBuilder.buildPageable(campaignCustomerRequestDTO); // Pageable pageable = SQLBuilder.buildPageable(searchCustomerRequestDTO);
if (pageable != null) { // if (pageable != null) {
query.setFirstResult(pageable.getPageNumber() * pageable.getPageSize()); // query.setFirstResult(pageable.getPageNumber() * pageable.getPageSize());
query.setMaxResults(pageable.getPageSize()); // query.setMaxResults(pageable.getPageSize());
} // }
Pageable pageable = PageRequest.of(searchCustomerRequestDTO.getPage(), searchCustomerRequestDTO.getPageSize(), Sort.by(searchCustomerRequestDTO.getSort()));
List<CustomerListDTO> data = query.list(); List<CustomerListDTO> data = query.list();
Page<CustomerListDTO> dataPage = new PageImpl<>(data, pageable, count); Page<CustomerListDTO> dataPage = new PageImpl<>(data, pageable, count);
......
...@@ -5,7 +5,6 @@ import java.nio.file.Paths; ...@@ -5,7 +5,6 @@ import java.nio.file.Paths;
import java.io.IOException; import java.io.IOException;
import com.viettel.campaign.web.dto.BaseDTO; import com.viettel.campaign.web.dto.BaseDTO;
import com.viettel.campaign.web.dto.request_dto.CampaignRequestDTO;
import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.ClassPathResource;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
......
package com.viettel.campaign.web.dto;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class CustomerCustomDTO {
Long customerListMappingId;
Long companySiteId;
Long customerListId;
Long customerId;
String name;
String description;
String companyName;
String customerType;
String currentAddress;
String mobileNumber;
String email;
}
...@@ -7,8 +7,9 @@ import java.util.List; ...@@ -7,8 +7,9 @@ import java.util.List;
@Getter @Getter
@Setter @Setter
public class DeleteCustomerRequestDTO { public class CustomerRequestDTO {
Long customerId; Long customerId;
Long customerListId; Long customerListId;
List<Long> customerIds; List<Long> ids;
Long companySiteId;
} }
...@@ -6,7 +6,7 @@ import lombok.Setter; ...@@ -6,7 +6,7 @@ import lombok.Setter;
@Getter @Getter
@Setter @Setter
public class CampaignCustomerRequestDTO extends BaseDTO { public class SearchCustomerRequestDTO extends BaseDTO {
String customerListCode; String customerListCode;
String customerListName; String customerListName;
String convertedDateFrom; String convertedDateFrom;
......
...@@ -4,8 +4,8 @@ import com.viettel.campaign.web.dto.CustomerDTO; ...@@ -4,8 +4,8 @@ import com.viettel.campaign.web.dto.CustomerDTO;
import com.viettel.campaign.web.dto.CustomerListDTO; import com.viettel.campaign.web.dto.CustomerListDTO;
import com.viettel.campaign.web.dto.ResultDTO; import com.viettel.campaign.web.dto.ResultDTO;
import com.viettel.campaign.service.CustomerService; import com.viettel.campaign.service.CustomerService;
import com.viettel.campaign.web.dto.request_dto.CampaignCustomerRequestDTO; import com.viettel.campaign.web.dto.request_dto.SearchCustomerRequestDTO;
import com.viettel.campaign.web.dto.request_dto.DeleteCustomerRequestDTO; import com.viettel.campaign.web.dto.request_dto.CustomerRequestDTO;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
...@@ -14,12 +14,11 @@ import org.springframework.stereotype.Controller; ...@@ -14,12 +14,11 @@ import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.validation.Valid; import javax.validation.Valid;
import java.util.List;
import java.util.Map; import java.util.Map;
@Controller @Controller
@RequestMapping("/ipcc/customer") @RequestMapping("/ipcc/customer")
@CrossOrigin("*") @CrossOrigin(origins = "*")
public class CustomerController { public class CustomerController {
private static final Logger LOGGER = Logger.getLogger(CustomerController.class); private static final Logger LOGGER = Logger.getLogger(CustomerController.class);
...@@ -29,8 +28,8 @@ public class CustomerController { ...@@ -29,8 +28,8 @@ public class CustomerController {
@GetMapping("/findAll") @GetMapping("/findAll")
@ResponseBody @ResponseBody
public ResponseEntity findAllCustomer(@RequestParam("page") int page, @RequestParam("pageSize") int pageSize, @RequestParam("sort") String sort) { public ResponseEntity findAllCustomer(@RequestParam("page") int page, @RequestParam("pageSize") int pageSize, @RequestParam("sort") String sort, @RequestParam("customerListId") long customerListId, @RequestParam("companySiteId") long companySiteId) {
Map result = customerService.listAllCustomer(page, pageSize, sort); ResultDTO result = customerService.listAllCustomer(page, pageSize, sort, customerListId, companySiteId);
return new ResponseEntity<>(result, HttpStatus.OK); return new ResponseEntity<>(result, HttpStatus.OK);
} }
...@@ -69,17 +68,17 @@ public class CustomerController { ...@@ -69,17 +68,17 @@ public class CustomerController {
@PostMapping("/delete") @PostMapping("/delete")
@ResponseBody @ResponseBody
public ResultDTO deleteCustomer(@RequestBody @Valid DeleteCustomerRequestDTO deleteCustomerRequestDTO) { public ResultDTO deleteCustomer(@RequestBody @Valid CustomerRequestDTO customerRequestDTO) {
ResultDTO result = new ResultDTO(); ResultDTO result = new ResultDTO();
result = customerService.deleteCustomer(deleteCustomerRequestDTO); result = customerService.deleteCustomer(customerRequestDTO);
return result; return result;
} }
@PostMapping("/deleteIds") @PostMapping("/deleteIds")
@ResponseBody @ResponseBody
public ResultDTO deleteIds(@RequestBody @Valid DeleteCustomerRequestDTO deleteCustomerRequestDTO) { public ResultDTO deleteIds(@RequestBody @Valid CustomerRequestDTO customerRequestDTO) {
ResultDTO result = new ResultDTO(); ResultDTO result = new ResultDTO();
result = customerService.deleteIds(deleteCustomerRequestDTO); result = customerService.deleteIds(customerRequestDTO);
return result; return result;
} }
...@@ -142,15 +141,15 @@ public class CustomerController { ...@@ -142,15 +141,15 @@ public class CustomerController {
@PostMapping("/deleteCustomerListIds") @PostMapping("/deleteCustomerListIds")
@ResponseBody @ResponseBody
public ResultDTO deleteCustomerListIds(@RequestBody @Valid List<Long> ids) { public ResultDTO deleteCustomerListIds(@RequestBody @Valid CustomerRequestDTO customerRequestDTO) {
ResultDTO result = new ResultDTO(); ResultDTO result = new ResultDTO();
result = customerService.deleteCustomerListIds(ids); result = customerService.deleteCustomerListIds(customerRequestDTO);
return result; return result;
} }
@RequestMapping(value = "/searchCustomerList", method = RequestMethod.POST) @RequestMapping(value = "/searchCustomerList", method = RequestMethod.POST)
public ResponseEntity searchCustomerList(@RequestBody CampaignCustomerRequestDTO campaignCustomerRequestDTO) { public ResponseEntity searchCustomerList(@RequestBody SearchCustomerRequestDTO searchCustomerRequestDTO) {
ResultDTO result = customerService.searchCustomerList(campaignCustomerRequestDTO); ResultDTO result = customerService.searchCustomerList(searchCustomerRequestDTO);
return new ResponseEntity<>(result, HttpStatus.OK); return new ResponseEntity<>(result, HttpStatus.OK);
} }
......
select
a.CUSTOMER_LIST_MAPPING_ID customerListMappingId,
a.COMPANY_SITE_ID companySiteId,
a.CUSTOMER_LIST_ID customerListId,
a.CUSTOMER_ID customerId,
b.NAME name,
b.DESCRIPTION description,
b.COMPANY_NAME companyName,
b.CUSTOMER_TYPE customerType,
b.CURRENT_ADDRESS currentAddress,
c.MOBILE mobileNumber,
d.EMAIL email
from CUSTOMER_LIST_MAPPING a
join CUSTOMER b on a.CUSTOMER_ID = b.CUSTOMER_ID
left join (SELECT CUSTOMER_ID, LISTAGG(CONTACT, ', ') WITHIN GROUP (ORDER BY NULL) AS MOBILE
FROM CUSTOMER_CONTACT WHERE CONTACT_TYPE = 5 GROUP BY CUSTOMER_ID) c on b.CUSTOMER_ID = c.CUSTOMER_ID
left join (SELECT CUSTOMER_ID, LISTAGG(CONTACT, ', ') WITHIN GROUP (ORDER BY NULL) AS EMAIL
FROM CUSTOMER_CONTACT WHERE CONTACT_TYPE = 2 GROUP BY CUSTOMER_ID) d on b.CUSTOMER_ID = d.CUSTOMER_ID
where 1 = 1
and COMPANY_SITE_ID = :p_company_site_id
and CUSTOMER_LIST_ID = :p_customer_list_id
...@@ -12,4 +12,5 @@ SELECT ...@@ -12,4 +12,5 @@ SELECT
DEPT_CREATE deptCreate DEPT_CREATE deptCreate
FROM CUSTOMER_LIST FROM CUSTOMER_LIST
WHERE 1 = 1 WHERE 1 = 1
AND CREATE_AT BETWEEN :p_date_from AND :p_date_to AND CREATE_AT BETWEEN to_date(:p_date_from, 'YYYYMMDD') AND to_date(:p_date_to, 'YYYYMMDD')
AND COMPANY_SITE_ID = :p_company_site_id
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment