Commit b94a9e27 authored by ='s avatar =

Merge remote-tracking branch 'origin/master'

parents b9e2bc71 00b43f0b
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4"> <module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="ExternalSystem" externalSystem="Maven" />
<component name="FacetManager"> <component name="FacetManager">
<facet type="Spring" name="Spring"> <facet type="Spring" name="Spring">
<configuration /> <configuration />
...@@ -15,200 +14,4 @@ ...@@ -15,200 +14,4 @@
</configuration> </configuration>
</facet> </facet>
</component> </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> </module>
\ No newline at end of file
package com.viettel.campaign.model;
import lombok.Getter;
import lombok.Setter;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.util.Date;
@Entity
@Table(name = "CUSTOMER_CONTACT")
@Getter
@Setter
public class CustomerContact {
@Id
@Basic(optional = false)
@NotNull
@Column(name = "CONTACT_ID")
private Long contactId;
@Column(name = "CUSTOMER_ID")
private Long customerId;
@Column(name = "CONTACT_TYPE")
private Short contactType;
@Column(name = "CONTACT")
private String contact;
@Column(name = "IS_DIRECT_LINE")
private Short isDirectLine;
@Column(name = "STATUS")
private Short status;
@Column(name = "CREATE_DATE")
@Temporal(TemporalType.TIMESTAMP)
private Date createDate;
@Column(name = "UPDATE_DATE")
@Temporal(TemporalType.TIMESTAMP)
private Date updateDate;
@Column(name = "CREATE_BY")
private String createBy;
@Column(name = "UPDATE_BY")
private String updateBy;
@Column(name = "START_DATE")
@Temporal(TemporalType.TIMESTAMP)
private Date startDate;
@Column(name = "END_DATE")
@Temporal(TemporalType.TIMESTAMP)
private Date endDate;
}
package com.viettel.campaign.repository;
import com.viettel.campaign.model.CustomerContact;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;
public interface CustomerContactRepository extends JpaRepository<CustomerContact, Long> {
List<CustomerContact> findByCustomerIdAndAndContactTypeAndContact(Long customerId, Short contactType, String contact);
}
...@@ -6,9 +6,27 @@ import org.springframework.data.jpa.repository.Modifying; ...@@ -6,9 +6,27 @@ import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param; import org.springframework.data.repository.query.Param;
import java.util.List;
public interface CustomerListMappingRepository extends JpaRepository<CustomerListMapping, Long> { public interface CustomerListMappingRepository extends JpaRepository<CustomerListMapping, Long> {
// ----------- customer ------------ //
@Modifying
@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, @Param("p_company_site_id") Long p_company_site_id);
@Modifying
@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_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 --------------- //
@Modifying
@Query("delete from CustomerListMapping c where c.customerListId=:p_customer_list_id and c.companySiteId=:p_company_site_id")
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=:customerListId") @Query("delete from CustomerListMapping c where c.customerListId in (:p_ids) and c.companySiteId=:p_company_site_id")
int deleteMappingByCustomerListId(@Param("customerListId") Long customerListId); int deleteMappingByCustomerListIds(@Param("p_ids") List<Long> p_ids, @Param("p_company_site_id") Long p_company_site_id);
} }
...@@ -10,11 +10,15 @@ import java.util.List; ...@@ -10,11 +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("delete from CustomerList c where c.customerListId in (:ids)") @Query("update CustomerList c set c.status = 0 where c.customerListId=:p_customer_list_id and c.companySiteId=:p_company_site_id")
int deleteCustomerListIds(@Param("ids") List<Long> ids); int deleteCustomerList(@Param("p_customer_list_id") Long p_customer_list_id, @Param("p_company_site_id") Long p_company_site_id);
@Modifying
@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, @Param("p_company_site_id") Long p_company_site_id);
} }
...@@ -16,6 +16,8 @@ public interface CustomerRepository extends JpaRepository<Customer, Long> { ...@@ -16,6 +16,8 @@ public interface CustomerRepository extends JpaRepository<Customer, Long> {
Page<Customer> findAll(Pageable pageable); Page<Customer> findAll(Pageable pageable);
List<Customer> findByCustomerId(Long customerId);
@Query("FROM Customer WHERE name = ?1") @Query("FROM Customer WHERE name = ?1")
List<Customer> findByName(String firstName, Pageable pageable); List<Customer> findByName(String firstName, Pageable pageable);
......
...@@ -21,6 +21,7 @@ import org.springframework.stereotype.Repository; ...@@ -21,6 +21,7 @@ import org.springframework.stereotype.Repository;
import javax.persistence.EntityManager; import javax.persistence.EntityManager;
import javax.persistence.Query; import javax.persistence.Query;
import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
...@@ -38,18 +39,17 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom { ...@@ -38,18 +39,17 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
ResultDTO result = new ResultDTO(); ResultDTO result = new ResultDTO();
List<CampaignDTO> lst = new ArrayList<>(); List<CampaignDTO> lst = new ArrayList<>();
StringBuilder expression = new StringBuilder() StringBuilder expression = new StringBuilder()
.append(" SELECT C.CAMPAIGN_CODE, C.CAMPAIGN_NAME, C.CONTENT, C.START_TIME, C.END_TIME, C.STATUS ") .append(" SELECT C.CAMPAIGN_CODE, C.CAMPAIGN_NAME, C.CONTENT, C.START_TIME, C.END_TIME, C.STATUS, CA.STATUS AS AGENT_STATUS ")
.append(" FROM CAMPAIGN C INNER JOIN CAMPAIGN_AGENT CA ON C.CAMPAIGN_ID = CA.CAMPAIGN_ID ") .append(" FROM CAMPAIGN C INNER JOIN CAMPAIGN_AGENT CA ON C.CAMPAIGN_ID = CA.CAMPAIGN_ID ")
.append(" WHERE 1 = 1 ") .append(" WHERE 1 = 1 ");
//.append(" AND CA.AGENT_ID = :pAgentId ") //.append(" AND CA.AGENT_ID = :pAgentId ")
.append(" AND C.STATUS IN (2,3) ");
if (!DataUtil.isNullOrEmpty(campaignRequestDto.getCampaignCode())) { if (!DataUtil.isNullOrEmpty(campaignRequestDto.getCampaignCode())) {
expression.append(" AND C.CAMPAIGN_ID IN (:pCampaingId) "); expression.append(" AND C.CAMPAIGN_CODE IN (:pCampaignCode) ");
} }
if (!DataUtil.isNullOrEmpty(campaignRequestDto.getCampaignName())) { if (!DataUtil.isNullOrEmpty(campaignRequestDto.getCampaignName())) {
expression.append(" AND UPPER(C.CAMPAIGN_NAME) LIKE CONCAT('%',:pCampaignName,'%') "); expression.append(" AND UPPER(C.CAMPAIGN_NAME) LIKE :pCampaignName ");
} }
if (!DataUtil.isNullOrZero(campaignRequestDto.getStatus().longValue())) { if (!DataUtil.isNullOrZero(campaignRequestDto.getStatus().longValue())) {
...@@ -89,40 +89,45 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom { ...@@ -89,40 +89,45 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
if (!DataUtil.isNullOrEmpty(campaignRequestDto.getCampaignCode())) { if (!DataUtil.isNullOrEmpty(campaignRequestDto.getCampaignCode())) {
String[] lstCode = campaignRequestDto.getCampaignCode().split(","); String[] lstCode = campaignRequestDto.getCampaignCode().split(",");
query.setParameter(":pCampaingId", lstCode); query.setParameter("pCampaignCode", lstCode);
} }
if (!DataUtil.isNullOrEmpty(campaignRequestDto.getCampaignName())) { if (!DataUtil.isNullOrEmpty(campaignRequestDto.getCampaignName())) {
query.setParameter(":pCampaignName", campaignRequestDto.getCampaignName().toUpperCase()); query.setParameter("pCampaignName", "%" +
campaignRequestDto.getCampaignName().toUpperCase()
.replace("\\", "\\\\")
.replaceAll("%", "\\\\%")
.replaceAll("_", "\\\\_")
+ "%");
} }
if (!DataUtil.isNullOrZero(campaignRequestDto.getStatus().longValue())) { if (!DataUtil.isNullOrZero(campaignRequestDto.getStatus().longValue())) {
if (campaignRequestDto.getStatus() != 0) if (campaignRequestDto.getStatus() != 0)
query.setParameter(":pStatus", campaignRequestDto.getStatus()); query.setParameter("pStatus", campaignRequestDto.getStatus());
} }
if (!DataUtil.isNullOrEmpty(campaignRequestDto.getFromDateFr())) { if (!DataUtil.isNullOrEmpty(campaignRequestDto.getFromDateFr())) {
query.setParameter(":pStartTimeFr", campaignRequestDto.getFromDateFr()); query.setParameter("pStartTimeFr", campaignRequestDto.getFromDateFr());
} }
if (!DataUtil.isNullOrEmpty(campaignRequestDto.getFromDateTo())) { if (!DataUtil.isNullOrEmpty(campaignRequestDto.getFromDateTo())) {
query.setParameter(":pStartTimeTo", campaignRequestDto.getFromDateTo()); query.setParameter("pStartTimeTo", campaignRequestDto.getFromDateTo());
} }
if (!DataUtil.isNullOrEmpty(campaignRequestDto.getToDateFr())) { if (!DataUtil.isNullOrEmpty(campaignRequestDto.getToDateFr())) {
query.setParameter(":pEndTimeFr", campaignRequestDto.getToDateFr()); query.setParameter("pEndTimeFr", campaignRequestDto.getToDateFr());
} }
if (!DataUtil.isNullOrEmpty(campaignRequestDto.getToDateTo())) { if (!DataUtil.isNullOrEmpty(campaignRequestDto.getToDateTo())) {
query.setParameter(":pEndTimeTo", campaignRequestDto.getToDateTo()); query.setParameter("pEndTimeTo", campaignRequestDto.getToDateTo());
} }
if (!DataUtil.isNullOrZero(campaignRequestDto.getNumOfCusFr())) { if (!DataUtil.isNullOrZero(campaignRequestDto.getNumOfCusFr())) {
query.setParameter(":pCustNumFr", campaignRequestDto.getNumOfCusFr()); query.setParameter("pCustNumFr", campaignRequestDto.getNumOfCusFr());
} }
if (!DataUtil.isNullOrZero(campaignRequestDto.getNumOfCusTo())) { if (!DataUtil.isNullOrZero(campaignRequestDto.getNumOfCusTo())) {
query.setParameter(":pCustNumTo", campaignRequestDto.getNumOfCusTo()); query.setParameter("pCustNumTo", campaignRequestDto.getNumOfCusTo());
} }
result.setTotalRow(query.getResultList().size()); result.setTotalRow(query.getResultList().size());
...@@ -145,7 +150,8 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom { ...@@ -145,7 +150,8 @@ public class CampaignRepositoryImpl implements CampaignRepositoryCustom {
item.setContent((String) obj[2]); item.setContent((String) obj[2]);
item.setStartTime((Date) obj[3]); item.setStartTime((Date) obj[3]);
item.setEndTime((Date) obj[4]); item.setEndTime((Date) obj[4]);
item.setStatus(((Short) obj[5])); item.setStatus(((BigDecimal) obj[5]).shortValueExact());
item.setAgentStatus(((BigDecimal) obj[6]).shortValueExact());
lst.add(item); lst.add(item);
} }
......
...@@ -3,22 +3,24 @@ package com.viettel.campaign.service; ...@@ -3,22 +3,24 @@ 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.SearchCustomerRequestDTO;
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);
Map listCustByName(int page, int pageSize, String sort, String name); Map listCustByName(int page, int pageSize, String sort, String name);
ResultDTO createCustomer(CustomerDTO customerDTO); ResultDTO createCustomer(CustomerDTO customerDTO);
ResultDTO deleteCustomer(CustomerDTO customerDTO); ResultDTO deleteCustomer(CustomerRequestDTO customerRequestDTO);
ResultDTO deleteIds(List<Long> ids); ResultDTO deleteIds(CustomerRequestDTO customerRequestDTO);
// ------------ customer list ------------ // // ------------ customer list ------------ //
...@@ -30,7 +32,15 @@ public interface CustomerService { ...@@ -30,7 +32,15 @@ public interface CustomerService {
ResultDTO deleteCustomerList(CustomerListDTO customerListDTO); ResultDTO deleteCustomerList(CustomerListDTO customerListDTO);
ResultDTO deleteCustomerListIds(List<Long> ids); ResultDTO deleteCustomerListIds(CustomerRequestDTO customerRequestDTO);
<<<<<<< HEAD
ResultDTO searchCustomerList(SearchCustomerRequestDTO searchCustomerRequestDTO);
=======
ResultDTO searchCustomerList(CampaignCustomerRequestDTO campaignCustomerRequestDTO);
// ------------ customer contact ------------ //
ResultDTO searchCustomerList(String customerListCode, String customerListName, Date dateFrom, Date dateTo, int page, int pageSize, String sort); ResultDTO getCustomerContact(Long customerId, Short contactType, String contact);
>>>>>>> 34ea2d6ca2abb80539da3dd29437f08fed559e93
} }
package com.viettel.campaign.service; package com.viettel.campaign.service.impl;
import com.viettel.campaign.service.CampaignCompleteCodeService;
import com.viettel.campaign.utils.Constants; import com.viettel.campaign.utils.Constants;
import com.viettel.campaign.web.dto.CampaignCompleteCodeDTO; import com.viettel.campaign.web.dto.CampaignCompleteCodeDTO;
import com.viettel.campaign.web.dto.ResultDTO; import com.viettel.campaign.web.dto.ResultDTO;
......
package com.viettel.campaign.service.impl; package com.viettel.campaign.service.impl;
import com.viettel.campaign.mapper.CustomerListMapper; import com.viettel.campaign.mapper.CustomerListMapper;
import com.viettel.campaign.model.CustomerContact;
import com.viettel.campaign.model.CustomerList; import com.viettel.campaign.model.CustomerList;
import com.viettel.campaign.repository.CampaignCustomerListRepository; import com.viettel.campaign.repository.*;
import com.viettel.campaign.repository.CustomerListMappingRepository;
import com.viettel.campaign.repository.CustomerListRepository;
import com.viettel.campaign.service.CustomerService; 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.repository.CustomerRepository;
import com.viettel.campaign.utils.DataUtil; import com.viettel.campaign.utils.DataUtil;
import com.viettel.campaign.web.dto.request_dto.SearchCustomerRequestDTO;
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;
import org.hibernate.transform.Transformers; import org.hibernate.transform.Transformers;
import org.hibernate.type.DateType;
import org.hibernate.type.LongType;
import org.hibernate.type.ShortType;
import org.hibernate.type.StringType;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.*; import org.springframework.data.domain.*;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -41,6 +46,9 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -41,6 +46,9 @@ public class CustomerServiceImpl implements CustomerService {
@Autowired @Autowired
CustomerListRepository customerListRepository; CustomerListRepository customerListRepository;
@Autowired
CustomerContactRepository customerContactRepository;
@Autowired @Autowired
CampaignCustomerListRepository campaignCustomerListRepository; CampaignCustomerListRepository campaignCustomerListRepository;
...@@ -48,17 +56,94 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -48,17 +56,94 @@ 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
public ResultDTO getCustomerId(Long customerId) {
ResultDTO resultDTO = new ResultDTO();
List<Customer> customer = customerRepository.findByCustomerId(customerId);
if (customer != null) {
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription("customer data");
resultDTO.setListData(customer);
} else {
resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
resultDTO.setDescription("customer data null");
}
return resultDTO;
} }
@Override @Override
...@@ -110,13 +195,15 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -110,13 +195,15 @@ public class CustomerServiceImpl implements CustomerService {
return resultDTO; return resultDTO;
} }
@Transactional
@Override @Override
public ResultDTO deleteCustomer(CustomerDTO customerDTO) { public ResultDTO deleteCustomer(CustomerRequestDTO customerRequestDTO) {
ResultDTO resultDTO = new ResultDTO(); ResultDTO resultDTO = new ResultDTO();
try { try {
if (customerDTO != null) { if (customerRequestDTO != null) {
// delete // delete
customerRepository.deleteById(customerDTO.getCustomerId()); // customerRepository.deleteById(customerDTO.getCustomerId());
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);
...@@ -133,11 +220,12 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -133,11 +220,12 @@ public class CustomerServiceImpl implements CustomerService {
@Transactional @Transactional
@Override @Override
public ResultDTO deleteIds(List<Long> ids) { public ResultDTO deleteIds(CustomerRequestDTO customerRequestDTO) {
ResultDTO resultDTO = new ResultDTO(); ResultDTO resultDTO = new ResultDTO();
try { try {
if (ids != null) { if (customerRequestDTO != null) {
customerRepository.deleteIds(ids); // customerRepository.deleteIds(ids);
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 {
...@@ -214,16 +302,22 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -214,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());
customerList = 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);
...@@ -239,16 +333,14 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -239,16 +333,14 @@ public class CustomerServiceImpl implements CustomerService {
@Override @Override
public ResultDTO deleteCustomerList(CustomerListDTO customerListDTO) { public ResultDTO deleteCustomerList(CustomerListDTO customerListDTO) {
ResultDTO resultDTO = new ResultDTO(); ResultDTO resultDTO = new ResultDTO();
CustomerListMapper customerListMapper = new CustomerListMapper();
CustomerList customerList = customerListRepository.findCustomerListByCustomerListId(customerListDTO.getCustomerListId());
try { try {
// delete // delete
if (DataUtil.isNullOrZero(campaignCustomerListRepository.campaignCount(customerListDTO.getCustomerListId()))) { if (DataUtil.isNullOrZero(campaignCustomerListRepository.campaignCount(customerListDTO.getCustomerListId()))) {
customerList = customerListMapper.toPersistenceBean(customerListDTO);
customerList = customerListRepository.save(customerList);
customerListMappingRepository.deleteMappingByCustomerListId(customerListDTO.getCustomerListId()); customerListRepository.deleteCustomerList(customerListDTO.getCustomerListId(), customerListDTO.getCompanySiteId());
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);
...@@ -266,12 +358,15 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -266,12 +358,15 @@ 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(customerRequestDTO.getIds(), customerRequestDTO.getCompanySiteId());
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS); resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS); resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS);
} else { } else {
...@@ -289,71 +384,108 @@ public class CustomerServiceImpl implements CustomerService { ...@@ -289,71 +384,108 @@ public class CustomerServiceImpl implements CustomerService {
} }
@Override @Override
public ResultDTO searchCustomerList(String customerListCode, String customerListName, Date dateFrom, Date dateTo, int page, int pageSize, String sort) { 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();
StringBuilder sqlStrBuilder = new StringBuilder(); if (DataUtil.isNullOrEmpty(searchCustomerRequestDTO.getCompanySiteId())) {
sqlStrBuilder.append(SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_MNG, "search-campaign-customer-by-params")); resultDTO.setErrorCode(Constants.ApiErrorCode.ERROR);
if (!customerListCode.equals("undefined")) { resultDTO.setDescription(Constants.ApiErrorDesc.ERROR);
sqlStrBuilder.append(" AND CUSTOMER_LIST_CODE LIKE :p_list_code"); return resultDTO;
}
if (!customerListName.equals("undefined")) {
sqlStrBuilder.append(" AND CUSTOMER_LIST_NAME LIKE :p_list_name");
} }
SQLQuery query = session.createSQLQuery(sqlStrBuilder.toString()); try {
StringBuilder sqlStrBuilder = new StringBuilder();
sqlStrBuilder.append(SQLBuilder.getSqlQueryById(SQLBuilder.SQL_MODULE_CAMPAIGN_MNG, "search-campaign-customer-by-params"));
if (!DataUtil.isNullOrEmpty(searchCustomerRequestDTO.getCustomerListCode())) {
sqlStrBuilder.append(" AND CUSTOMER_LIST_CODE LIKE :p_list_code");
}
if (!DataUtil.isNullOrEmpty(searchCustomerRequestDTO.getCustomerListName())) {
sqlStrBuilder.append(" AND CUSTOMER_LIST_NAME LIKE :p_list_name");
}
query.setParameter("p_date_from", dateFrom); SQLQuery query = session.createSQLQuery(sqlStrBuilder.toString());
query.setParameter("p_date_to", dateTo);
if (!customerListCode.equals("undefined")) { query.setParameter("p_date_from", searchCustomerRequestDTO.getConvertedDateFrom());
query.setParameter("p_list_code", "%" + query.setParameter("p_date_to", searchCustomerRequestDTO.getConvertedDateTo());
customerListCode query.setParameter("p_company_site_id", searchCustomerRequestDTO.getCompanySiteId());
.replace("\\", "\\\\")
.replaceAll("%", "\\\\%")
.replaceAll("_", "\\\\_")
+ "%");
}
if (!customerListName.equals("undefined")) { if (!DataUtil.isNullOrEmpty(searchCustomerRequestDTO.getCustomerListCode())) {
query.setParameter("p_list_name", "%" + query.setParameter("p_list_code", "%" +
customerListName searchCustomerRequestDTO.getCustomerListCode()
.replace("\\", "\\\\") .replace("\\", "\\\\")
.replaceAll("%", "\\\\%") .replaceAll("%", "\\%")
.replaceAll("_", "\\\\_") .replaceAll("_", "\\_")
+ "%"); + "%");
} }
// Pageable pageable = PageRequest.of(page, pageSize, Sort.by(sort)); if (!DataUtil.isNullOrEmpty(searchCustomerRequestDTO.getCustomerListName())) {
// Page<CustomerList> pc = customerListRepository.search(); query.setParameter("p_list_name", "%" +
// searchCustomerRequestDTO.getCustomerListName()
// result.put("totalItem", pc.getTotalElements()); .replace("\\", "\\\\")
// result.put("searchList", pc.iterator()); .replaceAll("%", "\\%")
query.setResultTransformer(Transformers.aliasToBean(CustomerListDTO.class)); .replaceAll("_", "\\_")
int count = 0; + "%");
List<CustomerListDTO> dtoList = query.list(); }
if (dtoList.size() > 0) {
count = query.list().size(); query.addScalar("customerListId", new LongType());
query.addScalar("companySiteId", new LongType());
query.addScalar("customerListCode", new StringType());
query.addScalar("customerListName", new StringType());
query.addScalar("status", new ShortType());
query.addScalar("createBy", new StringType());
query.addScalar("createAt", new DateType());
query.addScalar("updateBy", new StringType());
query.addScalar("updateAt", new DateType());
query.addScalar("source", new StringType());
query.addScalar("deptCreate", new StringType());
query.setResultTransformer(Transformers.aliasToBean(CustomerListDTO.class));
int count = 0;
List<CustomerListDTO> dtoList = query.list();
if (dtoList.size() > 0) {
count = query.list().size();
}
// Pageable pageable = SQLBuilder.buildPageable(searchCustomerRequestDTO);
// if (pageable != null) {
// query.setFirstResult(pageable.getPageNumber() * pageable.getPageSize());
// query.setMaxResults(pageable.getPageSize());
// }
Pageable pageable = PageRequest.of(searchCustomerRequestDTO.getPage(), searchCustomerRequestDTO.getPageSize(), Sort.by(searchCustomerRequestDTO.getSort()));
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();
} }
// Pageable pageable = buildPageable();
// if (pageable != null) {
// query.setFirstResult(pageable.getPageNumber() * pageable.getPageSize());
// query.setMaxResults(pageable.getPageSize());
// }
Pageable pageable = PageRequest.of(page, pageSize, Sort.by(sort)); return resultDTO;
}
List<CustomerListDTO> data = query.list(); @Override
Page<CustomerListDTO> dataPage = new PageImpl<>(data, pageable, count); public ResultDTO getCustomerContact(Long customerId, Short contactType, String contact) {
resultDTO.setData(dataPage); ResultDTO result = new ResultDTO();
resultDTO.setErrorCode(Constants.ApiErrorCode.SUCCESS);
resultDTO.setDescription(Constants.ApiErrorDesc.SUCCESS); List<CustomerContact> customer = customerContactRepository.findByCustomerIdAndAndContactTypeAndContact(customerId, contactType, contact);
session.close();
if (customer != null) {
result.setErrorCode(Constants.ApiErrorCode.SUCCESS);
result.setDescription("customer contact data");
result.setListData(customer);
} else {
result.setErrorCode(Constants.ApiErrorCode.ERROR);
result.setDescription("customer contact data null");
}
return resultDTO; return result;
} }
} }
...@@ -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;
...@@ -17,7 +16,6 @@ import org.springframework.data.domain.Sort; ...@@ -17,7 +16,6 @@ import org.springframework.data.domain.Sort;
public class SQLBuilder { public class SQLBuilder {
public static final String SQL_MODULE_CAMPAIGN_MNG = "campaign-mng"; public static final String SQL_MODULE_CAMPAIGN_MNG = "campaign-mng";
public static final String SQL_MODULE_CAMPAIGN_STATUS_MNG = "campaign-status-mng"; public static final String SQL_MODULE_CAMPAIGN_STATUS_MNG = "campaign-status-mng";
public static final String SQL_MODULE_CAMPAIGN_CUSTOMER = "campaign-customer";
public static String getSqlQueryById(String module, public static String getSqlQueryById(String module,
String queryId) { String queryId) {
......
...@@ -57,6 +57,5 @@ public class CampaignDTO extends BaseDTO { ...@@ -57,6 +57,5 @@ public class CampaignDTO extends BaseDTO {
private Long numOfNotJoinedCus; private Long numOfNotJoinedCus;
private Long numOfLockCus; private Long numOfLockCus;
private String campaignTypeName; private String campaignTypeName;
private Short agentStatus;
} }
package com.viettel.campaign.web.dto;
import lombok.Getter;
import lombok.Setter;
import java.util.Date;
@Getter
@Setter
public class CustomerContactDTO {
private Long contactId;
private Long customerId;
private Short contactType;
private String contact;
private Short isDirectLine;
private Short status;
private Date createDate;
private Date updateDate;
private String createBy;
private String updateBy;
private Date startDate;
private Date endDate;
}
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;
}
package com.viettel.campaign.web.dto.request_dto;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
@Getter
@Setter
public class CustomerRequestDTO {
Long customerId;
Long customerListId;
List<Long> ids;
Long companySiteId;
}
package com.viettel.campaign.web.dto.request_dto;
import com.viettel.campaign.web.dto.BaseDTO;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class SearchCustomerRequestDTO extends BaseDTO {
String customerListCode;
String customerListName;
String convertedDateFrom;
String convertedDateTo;
String companySiteId;
}
...@@ -4,6 +4,8 @@ import com.viettel.campaign.web.dto.CustomerDTO; ...@@ -4,6 +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.SearchCustomerRequestDTO;
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;
...@@ -12,13 +14,11 @@ import org.springframework.stereotype.Controller; ...@@ -12,13 +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.Date;
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);
...@@ -28,11 +28,18 @@ public class CustomerController { ...@@ -28,11 +28,18 @@ 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);
} }
@GetMapping("/findCustomerId")
@ResponseBody
public ResponseEntity<ResultDTO> findAllCustomerName(@RequestParam("customerId") Long customerId) {
ResultDTO result = customerService.getCustomerId(customerId);
return new ResponseEntity(result, HttpStatus.OK);
}
@GetMapping("/findCustomerByName") @GetMapping("/findCustomerByName")
@ResponseBody @ResponseBody
public ResponseEntity findAllCustomerName(@RequestParam("page") int page, @RequestParam("pageSize") int pageSize, @RequestParam("sort") String sort, @RequestParam("name") String name) { public ResponseEntity findAllCustomerName(@RequestParam("page") int page, @RequestParam("pageSize") int pageSize, @RequestParam("sort") String sort, @RequestParam("name") String name) {
...@@ -61,17 +68,17 @@ public class CustomerController { ...@@ -61,17 +68,17 @@ public class CustomerController {
@PostMapping("/delete") @PostMapping("/delete")
@ResponseBody @ResponseBody
public ResultDTO deleteCustomer(@RequestBody @Valid CustomerDTO customerDTO) { public ResultDTO deleteCustomer(@RequestBody @Valid CustomerRequestDTO customerRequestDTO) {
ResultDTO result = new ResultDTO(); ResultDTO result = new ResultDTO();
result = customerService.deleteCustomer(customerDTO); result = customerService.deleteCustomer(customerRequestDTO);
return result; return result;
} }
@PostMapping("/deleteIds") @PostMapping("/deleteIds")
@ResponseBody @ResponseBody
public ResultDTO deleteIds(@RequestBody @Valid List<Long> ids) { public ResultDTO deleteIds(@RequestBody @Valid CustomerRequestDTO customerRequestDTO) {
ResultDTO result = new ResultDTO(); ResultDTO result = new ResultDTO();
result = customerService.deleteIds(ids); result = customerService.deleteIds(customerRequestDTO);
return result; return result;
} }
...@@ -134,16 +141,22 @@ public class CustomerController { ...@@ -134,16 +141,22 @@ 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;
} }
@GetMapping("/searchCustomerList") @RequestMapping(value = "/searchCustomerList", method = RequestMethod.POST)
@ResponseBody public ResponseEntity searchCustomerList(@RequestBody SearchCustomerRequestDTO searchCustomerRequestDTO) {
public ResponseEntity searchCustomerList(@RequestParam("customerListCode") String customerListCode, @RequestParam("customerListName") String customerListName, @RequestParam("dateFrom") Date dateFrom, @RequestParam("dateTo") Date dateTo, @RequestParam("page") int page, @RequestParam("pageSize") int pageSize, @RequestParam("sort") String sort) { ResultDTO result = customerService.searchCustomerList(searchCustomerRequestDTO);
ResultDTO result = customerService.searchCustomerList(customerListCode, customerListName, dateFrom, dateTo, page, pageSize, sort);
return new ResponseEntity<>(result, HttpStatus.OK); return new ResponseEntity<>(result, HttpStatus.OK);
} }
@GetMapping("/findCustomerContact")
@ResponseBody
public ResponseEntity<ResultDTO> findAllCustomerContact(@RequestParam("customerId") Long customerId, @RequestParam("contactType") Short contactType, @RequestParam("contact") String contact) {
ResultDTO result = customerService.getCustomerContact(customerId, contactType, contact);
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
SELECT SELECT
CUSTOMER_LIST_ID, CUSTOMER_LIST_ID customerListId,
COMPANY_SITE_ID, COMPANY_SITE_ID companySiteId,
CUSTOMER_LIST_CODE, CUSTOMER_LIST_CODE customerListCode,
CUSTOMER_LIST_NAME, CUSTOMER_LIST_NAME customerListName,
STATUS, STATUS status,
CREATE_BY, CREATE_BY createBy,
CREATE_AT, CREATE_AT createAt,
UPDATE_BY, UPDATE_BY updateBy,
UPDATE_AT, UPDATE_AT updateAt,
SOURCE, SOURCE source,
DEPT_CREATE 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