otp resend otp, user activity implemented
parent
c512fedf60
commit
31ff361e90
@ -0,0 +1,78 @@
|
|||||||
|
package com.mfsys.uco.constants;
|
||||||
|
|
||||||
|
import com.mfsys.uco.model.CustomerAccountActivity;
|
||||||
|
import com.mfsys.uco.model.CustomerProfile;
|
||||||
|
import com.mfsys.uco.repository.CustomerProfileRepository;
|
||||||
|
import com.mfsys.uco.service.CustomerAccountActivityService;
|
||||||
|
import jakarta.servlet.FilterChain;
|
||||||
|
import jakarta.servlet.ServletException;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.filter.OncePerRequestFilter;
|
||||||
|
import org.springframework.web.util.ContentCachingResponseWrapper;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URLDecoder;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
@Component
|
||||||
|
public class LoggingActivityFilter extends OncePerRequestFilter {
|
||||||
|
private static final Logger LOGGER = LoggerFactory.getLogger(LoggingActivityFilter.class);
|
||||||
|
private final CustomerProfileRepository customerProfileRepository;
|
||||||
|
private final CustomerAccountActivityService custAccActivityService;
|
||||||
|
|
||||||
|
public LoggingActivityFilter(CustomerProfileRepository customerProfileRepository, CustomerAccountActivityService custAccActivityService) {
|
||||||
|
this.customerProfileRepository = customerProfileRepository;
|
||||||
|
this.custAccActivityService = custAccActivityService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
|
||||||
|
response.setHeader("Access-Control-Allow-Credentials", "true");
|
||||||
|
response.setHeader("Access-Control-Allow-Origin", "*");
|
||||||
|
response.setHeader("Access-Control-Allow-Headers", "*");
|
||||||
|
response.setHeader("Access-Control-Expose-Headers", "*");
|
||||||
|
response.setHeader("Access-Control-Allow-Methods", "GET, POST, PATCH, PUT, DELETE, OPTIONS");
|
||||||
|
if (!(request.getMethod().equals("OPTIONS"))) {
|
||||||
|
filterChain.doFilter(request, response);
|
||||||
|
}
|
||||||
|
|
||||||
|
ContentCachingResponseWrapper responseWrapper = new ContentCachingResponseWrapper(response);
|
||||||
|
LOGGER.info(
|
||||||
|
"FINISHED PROCESSING: METHOD={}; REQUESTURI={}; RESPONSE CODE={}; IP={};",
|
||||||
|
request.getMethod(),
|
||||||
|
request.getRequestURI(),
|
||||||
|
response.getStatus(),
|
||||||
|
request.getRemoteAddr()
|
||||||
|
);
|
||||||
|
|
||||||
|
CustomerProfile cust;
|
||||||
|
String susUsercode = "";
|
||||||
|
if(request.getHeader("cmpUserId")!=null) {
|
||||||
|
susUsercode = URLDecoder.decode(request.getHeader("cmpUserId"), "UTF-8");
|
||||||
|
}
|
||||||
|
String porOrgacode = request.getHeader("porOrgacode");
|
||||||
|
String email = request.getHeader("email");
|
||||||
|
String channalCode = request.getHeader("channelCode");
|
||||||
|
String deviceName = request.getHeader("deviceName");
|
||||||
|
String userActivity = request.getHeader("userActivity");
|
||||||
|
cust = customerProfileRepository.findbyEmail(porOrgacode,email);
|
||||||
|
LocalDateTime date = LocalDateTime.now();
|
||||||
|
|
||||||
|
if (cust != null && userActivity!=null) {
|
||||||
|
CustomerAccountActivity activity = new CustomerAccountActivity(
|
||||||
|
null,
|
||||||
|
porOrgacode,
|
||||||
|
cust.getCmpCustcode(),
|
||||||
|
date,
|
||||||
|
channalCode,
|
||||||
|
deviceName,
|
||||||
|
userActivity,
|
||||||
|
cust
|
||||||
|
);
|
||||||
|
custAccActivityService.postCustomerAccountActivity(activity);;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,44 @@
|
|||||||
|
package com.mfsys.uco.model;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import com.mfsys.comm.util.FieldNameLength;
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class CustomerAccountActivity {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy= GenerationType.AUTO)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Column(name = "POR_ORGACODE", nullable = false, updatable = false, columnDefinition = FieldNameLength.POR_ORGACODE)
|
||||||
|
private String porOrgacode;
|
||||||
|
|
||||||
|
|
||||||
|
@Column(name = "CMP_CUSTCODE", nullable = false, updatable = false, columnDefinition = FieldNameLength.CUSTOMER_CODE)
|
||||||
|
private String cmpCustcode;
|
||||||
|
private LocalDateTime date;
|
||||||
|
private String channal;
|
||||||
|
private String deviceName;
|
||||||
|
private String activity;
|
||||||
|
|
||||||
|
|
||||||
|
@JsonIgnore
|
||||||
|
@ManyToOne(fetch = FetchType.LAZY)
|
||||||
|
@JoinColumns({
|
||||||
|
@JoinColumn(name = "POR_ORGACODE", referencedColumnName = "POR_ORGACODE", insertable = false, updatable = false),
|
||||||
|
@JoinColumn(name = "CMP_CUSTCODE", referencedColumnName = "CMP_CUSTCODE", insertable = false, updatable = false)})
|
||||||
|
private CustomerProfile customer;
|
||||||
|
|
||||||
|
|
||||||
|
public CustomerAccountActivity() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,17 @@
|
|||||||
|
package com.mfsys.uco.repository;
|
||||||
|
|
||||||
|
import com.mfsys.uco.model.CustomerAccountActivity;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface CustomerAccountActivityRepository extends JpaRepository<CustomerAccountActivity, Integer> {
|
||||||
|
|
||||||
|
@Query("SELECT cust FROM CustomerAccountActivity cust WHERE cust.cmpCustcode = :cmpUserId AND DATE(cust.date) BETWEEN DATE(:fdate) AND DATE(:tdate)")
|
||||||
|
List<CustomerAccountActivity> findAllByCmpUserIdAndDateBetween(String cmpUserId, String fdate, String tdate);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@ -0,0 +1,31 @@
|
|||||||
|
package com.mfsys.uco.service;
|
||||||
|
|
||||||
|
import com.mfsys.uco.model.CustomerAccountActivity;
|
||||||
|
import com.mfsys.uco.repository.CustomerAccountActivityRepository;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class CustomerAccountActivityService {
|
||||||
|
|
||||||
|
private CustomerAccountActivityRepository customerAccountActivityRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public CustomerAccountActivityService(CustomerAccountActivityRepository customerAccountActivityRepository) {
|
||||||
|
this.customerAccountActivityRepository = customerAccountActivityRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<CustomerAccountActivity> getCustomerAccountActivity(String porOrgacode, String pctCstycode,
|
||||||
|
String cmpCustcode, String cmpUserId, String fdate, String tdate) {
|
||||||
|
|
||||||
|
return customerAccountActivityRepository.findAllByCmpUserIdAndDateBetween(cmpUserId, fdate, tdate);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void postCustomerAccountActivity(CustomerAccountActivity customerAccountActivity) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
customerAccountActivityRepository.save(customerAccountActivity);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue