chore: copy kept Tastefully modules and portals into Co-Lite

Backend modules from tastefully 8bd93d15: core-libs, core-session,
api-gateway, mobile-api, services-auth, services-system,
services-counter, services-member, services-log, services-email.
solvway-admin-portal from babyboo f64d096ea, solvway-customer-portal
from tastefully 8bd93d15. Copied as tracked files only.

Literal secrets replaced with environment placeholders:
- services-email: SMTP_PASSWORD, MAILGUN_API_KEY, SENDGRID_API_KEY,
  MAILJET_API_KEY, MAILJET_SECRET_KEY (optional, empty default)
- services-system: JUMIO_TOKEN, JUMIO_SECRET (optional)
- services-auth: USER_AUTH_API_SECRET (required); commented JWT secret removed
- core-libs: JWT_TOKEN default removed (required), XXL_JOB_TOKEN default
  removed, ipgeolocation key read from IPGEOLOCATION_API_KEY
- services-system EkycAppConfig: commented Jumio credentials removed

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
This commit is contained in:
ngqileandClaude Opus 5.5 committed 2026-11-26 15:55:45 +08:00
1 parent e396568cc3
commit 5ee51d1913
2918 files changed
+302373 -3

No files matched your search

@@ -0,0 +1,14 @@
package com.solvway.services.email.util;
import com.mashape.unirest.http.HttpMethod;
import com.mashape.unirest.http.Unirest;
public class CustomUnirest extends Unirest{
public static CustomeHttpRequestWithBody customPost(String url) {
return new CustomeHttpRequestWithBody(HttpMethod.POST, url);
}
}
@@ -0,0 +1,180 @@
package com.solvway.services.email.util;
import com.mashape.unirest.http.HttpMethod;
import com.mashape.unirest.http.JsonNode;
import com.mashape.unirest.http.ObjectMapper;
import com.mashape.unirest.http.options.Option;
import com.mashape.unirest.http.options.Options;
import com.mashape.unirest.request.HttpRequest;
import com.mashape.unirest.request.body.MultipartBody;
import com.mashape.unirest.request.body.RawBody;
import com.mashape.unirest.request.body.RequestBodyEntity;
import com.solvway.services.email.model.Attachment;
import com.solvway.services.email.service.DriveService;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.mime.content.InputStreamBody;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.util.StringUtils;
import java.io.File;
import java.io.InputStream;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
public class CustomeHttpRequestWithBody extends HttpRequest{
public CustomeHttpRequestWithBody(HttpMethod method, String url) {
super(method, url);
// TODO Auto-generated constructor stub
}
@Override
public CustomeHttpRequestWithBody routeParam(String name, String value) {
super.routeParam(name, value);
return this;
}
@Override
public CustomeHttpRequestWithBody header(String name, String value) {
return (CustomeHttpRequestWithBody) super.header(name, value);
}
@Override
public CustomeHttpRequestWithBody headers(Map<String, String> headers) {
return (CustomeHttpRequestWithBody) super.headers(headers);
}
@Override
public CustomeHttpRequestWithBody basicAuth(String username, String password) {
super.basicAuth(username, password);
return this;
}
@Override
public CustomeHttpRequestWithBody queryString(Map<String, Object> parameters) {
return (CustomeHttpRequestWithBody) super.queryString(parameters);
}
@Override
public CustomeHttpRequestWithBody queryString(String name, Object value) {
return (CustomeHttpRequestWithBody) super.queryString(name, value);
}
public MultipartBody field(String name, Collection<?> value) {
MultipartBody body = new MultipartBody(this).field(name, value);
this.body = body;
return body;
}
public MultipartBody field(String name, Object value) {
return field(name, value, null);
}
public MultipartBody field(String name, File file) {
return field(name, file, null);
}
public MultipartBody field(String name, Object value, String contentType) {
MultipartBody body = new MultipartBody(this).field(name, (value == null) ? "" : value.toString(), contentType);
this.body = body;
return body;
}
public MultipartBody field(String name, File file, String contentType) {
MultipartBody body = new MultipartBody(this).field(name, file, contentType);
this.body = body;
return body;
}
public MultipartBody fields(Map<String, Object> parameters) {
MultipartBody body = new MultipartBody(this);
if (parameters != null) {
for (Entry<String, Object> param : parameters.entrySet()) {
if (param.getValue() instanceof File) {
body.field(param.getKey(), (File) param.getValue());
} else {
body.field(param.getKey(), (param.getValue() == null) ? "" : param.getValue().toString());
}
}
}
this.body = body;
return body;
}
public MultipartBody field(String name, InputStream stream, ContentType contentType, String fileName) {
InputStreamBody inputStreamBody = new InputStreamBody(stream, contentType, fileName);
MultipartBody body = new MultipartBody(this).field(name, inputStreamBody, true, contentType.toString());
this.body = body;
return body;
}
public MultipartBody field(String name, InputStream stream, String fileName) {
MultipartBody body = field(name, stream, ContentType.APPLICATION_OCTET_STREAM, fileName);
this.body = body;
return body;
}
public RequestBodyEntity body(JsonNode body) {
return body(body.toString());
}
public RequestBodyEntity body(String body) {
RequestBodyEntity b = new RequestBodyEntity(this).body(body);
this.body = b;
return b;
}
public RequestBodyEntity body(Object body) {
ObjectMapper objectMapper = (ObjectMapper) Options.getOption(Option.OBJECT_MAPPER);
if (objectMapper == null) {
throw new RuntimeException("Serialization Impossible. Can't find an ObjectMapper implementation.");
}
return body(objectMapper.writeValue(body));
}
public RawBody body(byte[] body) {
RawBody b = new RawBody(this).body(body);
this.body = b;
return b;
}
/**
* Sugar method for body operation
*
* @param body raw org.JSONObject
* @return RequestBodyEntity instance
*/
public RequestBodyEntity body(JSONObject body) {
return body(body.toString());
}
/**
* Sugar method for body operation
*
* @param body raw org.JSONArray
* @return RequestBodyEntity instance
*/
public RequestBodyEntity body(JSONArray body) {
return body(body.toString());
}
public MultipartBody customeAddBody(String str, List<Attachment> list, DriveService driveService) {
MultipartBody body = null;
for(Attachment atch: list) {
byte[] data = !StringUtils.hasLength(atch.getBucketFileId())? atch.getData(): driveService.loadPrivateFile(atch.getBucketFileId());
body = Objects.requireNonNullElseGet(body, () -> new MultipartBody(this)).field(str, data, atch.getFileName());
this.body = body;
}
return body;
}
}
@@ -0,0 +1,83 @@
package com.solvway.services.email.util;
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;
import com.mashape.unirest.http.exceptions.UnirestException;
import com.solvway.core.enums.EmailEnum.RecipientType;
import com.solvway.services.email.model.Attachment;
import com.solvway.services.email.model.Email;
import com.solvway.services.email.model.Recipient;
import com.solvway.services.email.service.DriveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.stream.Collectors;
@Service("mailGunRestClient")
public class MailGunRestClient {
@Autowired
private DriveService driveService;
// private RestTemplate restTemplate;
//
// @Autowired
// public MailGunRestClient(RestTemplateBuilder builder) {
// this.restTemplate = builder.build();
// }
//
// public Object post(String resourceUrl, MultiValueMap<String, Object> request, String username, String password) {
// HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(request,
// createHeadersWithUsernamePassword(username, password));
// ResponseEntity<String> response = this.restTemplate.exchange(resourceUrl, HttpMethod.POST, requestEntity, String.class);
// Object postObject = response.getBody();
// return postObject;
// }
//
// private HttpHeaders createHeadersWithUsernamePassword(String username, String password) {
// return new HttpHeaders() {
// {
// String auth = username + ":" + password;
// byte[] encodedAuth = Base64.getEncoder().encode(auth.getBytes(Charset.forName("US-ASCII")));
// String authHeader = "Basic " + new String(encodedAuth);
// set("Accept", MediaType.APPLICATION_JSON.toString());
// set("Content-Type", MediaType.APPLICATION_FORM_URLENCODED.toString());
// set("Authorization", authHeader);
// }
// };
// }
public String sendEmailMessage(String resourceUrl, Email email, List<Attachment> attch, String username,
String password) throws UnirestException {
if (attch!=null && !attch.isEmpty()) {
// send with attachemnt
HttpResponse<String> request = CustomUnirest.customPost(resourceUrl).basicAuth("api", password)
.customeAddBody("attachment", attch, driveService)
.field("from", email.getSender())
.field("subject", email.getSubject())
.field("html", email.getBody())
.field("to",filterRecipient(email, RecipientType.R))
.field("cc", filterRecipient(email, RecipientType.CC))
.asString();
return request.getBody();
} else {
// send without attachemnt
HttpResponse<String> request = Unirest.post(resourceUrl).basicAuth("api", password)
.field("from", email.getSender())
.field("subject", email.getSubject())
.field("html", email.getBody())
.field("to",filterRecipient(email, RecipientType.R))
.field("cc", filterRecipient(email, RecipientType.CC))
.asString();
return request.getBody();
}
}
public List<String> filterRecipient(Email email, RecipientType type) {
List<Recipient> rcp = email.getRecipients().stream().filter(x -> x.getType() == type)
.toList();
return rcp.parallelStream().map(Recipient::getRecipient).collect(Collectors.toList());
}
}
@@ -0,0 +1,56 @@
package com.solvway.services.email.util;
import lombok.Getter;
import org.springframework.data.redis.core.HashOperations;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Component;
import java.util.Map;
import java.util.concurrent.TimeUnit;
@Component
public class RedisUtil<T> {
@Getter
private final RedisTemplate<String, T> redisTemplate;
private final HashOperations<String, Object, T> hashOperation;
private final ValueOperations<String, T> valueOperations;
public RedisUtil(RedisTemplate<String,T> redisTemplate){
this.redisTemplate = redisTemplate;
this.hashOperation = redisTemplate.opsForHash();
this.valueOperations = redisTemplate.opsForValue();
}
public void putMap(String redisKey, Object key, T data) {
hashOperation.put(redisKey, key, data);
}
public T getMapAsSingleEntry(String redisKey, Object key) {
return hashOperation.get(redisKey, key);
}
public Map<Object, T> getMapAsAll(String redisKey) {
return hashOperation.entries(redisKey);
}
public void putValue(String key, T value) {
valueOperations.set(key, value);
}
public void putValueWithExpireTime(String key, T value, long timeout, TimeUnit unit) {
valueOperations.set(key, value, timeout, unit);
}
public T getValue(String key) {
return valueOperations.get(key);
}
public void setExpire(String key, long timeout, TimeUnit unit) {
redisTemplate.expire(key, timeout, unit);
}
}
@@ -0,0 +1,49 @@
package com.solvway.services.email.util.paging;
import lombok.Getter;
import lombok.Setter;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.data.domain.Sort.Order;
import java.util.ArrayList;
import java.util.Iterator;
@Getter
public class PageableRest {
@Setter
@Getter
public static class SortRest {
public String direction;
public String property;
}
@Setter
public int number;
@Setter
public int size;
public ArrayList<SortRest> sorts;
public void setSorts(ArrayList<SortRest> sorts) {
if(this.sorts==null) {
this.sorts = new ArrayList<>();
}
this.sorts = sorts;
}
public Sort getSort() {
Iterator<SortRest> it = this.sorts.iterator();
Sort sort = null;
while (it.hasNext()) {
SortRest sr = it.next();
if(sort == null) {
sort = Sort.by(new Order(Direction.valueOf(sr.getDirection()), sr.getProperty()));
}else {
sort = sort.and(Sort.by(new Order(Direction.valueOf(sr.getDirection()), sr.getProperty())));
}
}
return sort;
}
}