You've already forked FrameTour-BE
Java21
This commit is contained in:
@ -53,7 +53,7 @@ public class BrokerBiz {
|
||||
expireDay = scenicConfig.getSampleStoreDay();
|
||||
}
|
||||
List<Long> brokerIdList = statisticsMapper.getBrokerIdListForUser(order.getMemberId(), DateUtil.offsetDay(DateUtil.beginOfDay(order.getCreateAt()), -expireDay), order.getCreateAt());
|
||||
Long directBrokerId = brokerIdList.get(0);
|
||||
Long directBrokerId = brokerIdList.getFirst();
|
||||
List<BrokerRespVO> brokerInfoList = brokerIdList.stream().map(brokerId -> {
|
||||
BrokerRespVO broker = brokerMapper.getById(brokerId);
|
||||
if (broker == null) {
|
||||
@ -77,7 +77,7 @@ public class BrokerBiz {
|
||||
if (brokerInfoList.size() == 1) {
|
||||
// 直接算佣金
|
||||
String reason = "单人提成:";
|
||||
BrokerRespVO broker = brokerInfoList.get(0);
|
||||
BrokerRespVO broker = brokerInfoList.getFirst();
|
||||
BrokerRecord brokerRecord = new BrokerRecord();
|
||||
brokerRecord.setBrokerId(broker.getId());
|
||||
brokerRecord.setOrderId(orderId);
|
||||
@ -95,7 +95,7 @@ public class BrokerBiz {
|
||||
brokerRecord.setReason(reason);
|
||||
brokerRecordList.add(brokerRecord);
|
||||
} else {
|
||||
BrokerRespVO broker = brokerInfoList.get(0);
|
||||
BrokerRespVO broker = brokerInfoList.getFirst();
|
||||
BigDecimal realRate = broker.getBrokerRate();
|
||||
BigDecimal brokerPrice = order.getPayPrice().multiply(realRate).divide(BigDecimal.valueOf(100), 2, RoundingMode.DOWN);
|
||||
// todo 需要计算实际提成比例
|
||||
@ -141,9 +141,7 @@ public class BrokerBiz {
|
||||
brokerRecordList.add(brokerRecord);
|
||||
}
|
||||
revokeOrder(orderId);
|
||||
brokerRecordList.forEach(brokerRecord -> {
|
||||
brokerRecordMapper.add(brokerRecord);
|
||||
});
|
||||
brokerRecordList.forEach(brokerRecordMapper::add);
|
||||
}
|
||||
|
||||
public void revokeOrder(Long orderId) {
|
||||
|
@ -166,15 +166,11 @@ public class OrderBiz {
|
||||
}
|
||||
// 免费送逻辑,之前已经赠送了的
|
||||
if (!isBuy) {
|
||||
switch (goodsType) {
|
||||
case 0:
|
||||
isBuy = videoRepository.getUserIsBuy(userId, goodsId);
|
||||
break;
|
||||
case 1:
|
||||
case 2:
|
||||
isBuy = sourceRepository.getUserIsBuy(userId, goodsType, goodsId);
|
||||
break;
|
||||
}
|
||||
isBuy = switch (goodsType) {
|
||||
case 0 -> videoRepository.getUserIsBuy(userId, goodsId);
|
||||
case 1, 2 -> sourceRepository.getUserIsBuy(userId, goodsType, goodsId);
|
||||
default -> false;
|
||||
};
|
||||
} else {
|
||||
OrderEntity orderEntity = orderRepository.getUserBuyItem(userId, goodsType, goodsId);
|
||||
if (orderEntity != null) {
|
||||
@ -257,7 +253,7 @@ public class OrderBiz {
|
||||
//商品创建时间
|
||||
Date goodsCreateTime = new Date();
|
||||
if (!orderDetail.getOrderItemList().isEmpty()) {
|
||||
OrderItemVO orderItemVO = orderDetail.getOrderItemList().get(0);
|
||||
OrderItemVO orderItemVO = orderDetail.getOrderItemList().getFirst();
|
||||
switch (orderItemVO.getGoodsType()) {
|
||||
case 0:
|
||||
VideoEntity video = videoRepository.getVideo(orderItemVO.getGoodsId());
|
||||
|
@ -112,7 +112,7 @@ public class TaskStatusBiz {
|
||||
int faceCutStatus = getFaceCutStatus(faceId);
|
||||
if (faceCutStatus != 1) {
|
||||
// 正在切片
|
||||
if (templateBiz.determineTemplateCanGenerate(templateList.get(0).getId(), faceId, false)) {
|
||||
if (templateBiz.determineTemplateCanGenerate(templateList.getFirst().getId(), faceId, false)) {
|
||||
response.setStatus(2);
|
||||
} else {
|
||||
response.setStatus(0);
|
||||
|
@ -107,7 +107,7 @@ public class TemplateBiz {
|
||||
List<SourceEntity> sourceEntities = sourceMapper.listVideoByScenicFaceRelation(face.getScenicId(), faceId);
|
||||
count = sourceEntities.stream()
|
||||
.map(SourceEntity::getDeviceId)
|
||||
.filter(deviceId -> deviceId != null) // 添加对 null 的检查
|
||||
.filter(Objects::nonNull) // 添加对 null 的检查
|
||||
.distinct()
|
||||
.filter(deviceId -> placeholderList.contains(deviceId.toString()))
|
||||
.count();
|
||||
|
@ -16,23 +16,23 @@ public class BaseContextHandler {
|
||||
}
|
||||
|
||||
public static void set(String key, Object value) {
|
||||
Object map;
|
||||
if ((map = (Map) threadLocal.get()) == null) {
|
||||
map = new HashMap();
|
||||
threadLocal.set((Map<String, Object>) map);
|
||||
Map<String, Object> map;
|
||||
if ((map = threadLocal.get()) == null) {
|
||||
map = new HashMap<>();
|
||||
threadLocal.set(map);
|
||||
}
|
||||
|
||||
((Map) map).put(key, value);
|
||||
map.put(key, value);
|
||||
}
|
||||
|
||||
public static Object get(String key) {
|
||||
Object map;
|
||||
if ((map = (Map) threadLocal.get()) == null) {
|
||||
map = new HashMap();
|
||||
threadLocal.set((Map<String, Object>) map);
|
||||
Map<String, Object> map;
|
||||
if ((map = threadLocal.get()) == null) {
|
||||
map = new HashMap<>();
|
||||
threadLocal.set(map);
|
||||
}
|
||||
|
||||
return ((Map) map).get(key);
|
||||
return (map).get(key);
|
||||
}
|
||||
|
||||
public static void setToken(String token) {
|
||||
|
@ -66,7 +66,7 @@ public class LyCompatibleController {
|
||||
@PostMapping("sendPhoto")
|
||||
@IgnoreToken
|
||||
public R sendPhoto(@RequestParam(value = "file", required = false) MultipartFile file, HttpServletRequest request) {
|
||||
Map<String, String> headersMap = new HashMap<String, String>();
|
||||
Map<String, String> headersMap = new HashMap<>();
|
||||
Enumeration<String> headerNames = request.getHeaderNames();
|
||||
while (headerNames.hasMoreElements()) {
|
||||
String key = (String) headerNames.nextElement();
|
||||
@ -123,7 +123,7 @@ public class LyCompatibleController {
|
||||
@RequestMapping("getIsVideo")
|
||||
@IgnoreToken
|
||||
public R getIsVideo(HttpServletRequest request) {
|
||||
Map<String, String> headersMap = new HashMap<String, String>();
|
||||
Map<String, String> headersMap = new HashMap<>();
|
||||
Enumeration<String> headerNames = request.getHeaderNames();
|
||||
while (headerNames.hasMoreElements()) {
|
||||
String key = (String) headerNames.nextElement();
|
||||
@ -165,7 +165,7 @@ public class LyCompatibleController {
|
||||
@RequestMapping("getNewVideo")
|
||||
@IgnoreToken
|
||||
public R getNewVideo(HttpServletRequest request) {
|
||||
Map<String, String> headersMap = new HashMap<String, String>();
|
||||
Map<String, String> headersMap = new HashMap<>();
|
||||
Enumeration<String> headerNames = request.getHeaderNames();
|
||||
while (headerNames.hasMoreElements()) {
|
||||
String key = (String) headerNames.nextElement();
|
||||
@ -204,7 +204,7 @@ public class LyCompatibleController {
|
||||
}
|
||||
List<Map<String, Object>> videoList = collect.get(0).stream().collect(Collectors.groupingBy(ContentPageVO::getTemplateId))
|
||||
.values().stream().map(contentPageVOs -> {
|
||||
ContentPageVO contentPageVO = contentPageVOs.get(0);
|
||||
ContentPageVO contentPageVO = contentPageVOs.getFirst();
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
VideoEntity videoRespVO = videoRepository.getVideo(contentPageVO.getContentId());
|
||||
map.put("id", videoRespVO.getId().toString());
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.ycwl.basic.controller.extern;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@ -11,6 +12,7 @@ import java.util.Map;
|
||||
* @date 2016年10月27日 下午9:59:27
|
||||
*/
|
||||
public class R extends HashMap<String, Object> {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public R() {
|
||||
|
@ -39,7 +39,7 @@ public class AppWxNotifyController {
|
||||
@GetMapping({"/getIds", "/"})
|
||||
@IgnoreToken
|
||||
public ApiResponse<List<String>> getIds() {
|
||||
return ApiResponse.success(new ArrayList<String>() {{
|
||||
return ApiResponse.success(new ArrayList<>() {{
|
||||
add("5b8vTm7kvwYubqDxb3dxBs0BqxMsgVgGw573aahTEd8");
|
||||
add("vPIzbkA0x4mMj-vdbWx6_45e8juWXzs3FGYnDsIPv3A");
|
||||
add("HB1vp-0BXc2WyYeoYN3a3GuZV9HtPLXUTT7blCBq9eY");
|
||||
@ -49,7 +49,7 @@ public class AppWxNotifyController {
|
||||
@GetMapping("/{scenicId}")
|
||||
@IgnoreToken
|
||||
public ApiResponse<List<String>> getIds(@PathVariable("scenicId") Long scenicId) {
|
||||
return ApiResponse.success(new ArrayList<String>() {{
|
||||
return ApiResponse.success(new ArrayList<>() {{
|
||||
String videoGeneratedTemplateId = scenicRepository.getVideoGeneratedTemplateId(scenicId);
|
||||
if (StringUtils.isNotBlank(videoGeneratedTemplateId)) {
|
||||
add(videoGeneratedTemplateId);
|
||||
|
@ -267,7 +267,7 @@ public class ViidController {
|
||||
}
|
||||
if (shotTime == null) {
|
||||
shotTime = new Date();
|
||||
} else if (Math.abs(shotTime.getTime() - System.currentTimeMillis()) > + 24 * 60 * 60 * 1000) {
|
||||
} else if (Math.abs(shotTime.getTime() - System.currentTimeMillis()) > 24 * 60 * 60 * 1000) {
|
||||
shotTime = new Date();
|
||||
}
|
||||
Long scenicId = device.getScenicId();
|
||||
@ -380,7 +380,7 @@ public class ViidController {
|
||||
faceSampleMapper.update(faceSample);
|
||||
}
|
||||
}
|
||||
if (deviceConfig != null && Integer.valueOf(1).equals(deviceConfig.getEnablePreBook())) {
|
||||
if (Integer.valueOf(1).equals(deviceConfig.getEnablePreBook())) {
|
||||
DynamicTaskGenerator.addTask(faceSample.getId());
|
||||
}
|
||||
});
|
||||
|
@ -117,6 +117,7 @@ public class VptPassiveStorageOperator extends ADeviceStorageOperator {
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
//noinspection BusyWait 得等待
|
||||
Thread.sleep(1000L);
|
||||
} catch (InterruptedException e) {
|
||||
return Collections.emptyList();
|
||||
|
@ -113,6 +113,7 @@ public class WvpPassiveStorageOperator extends ADeviceStorageOperator {
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
//noinspection BusyWait 得等待
|
||||
Thread.sleep(1000L);
|
||||
} catch (InterruptedException e) {
|
||||
return Collections.emptyList();
|
||||
|
@ -2,11 +2,13 @@ package com.ycwl.basic.exception;
|
||||
|
||||
import com.ycwl.basic.enums.BizCodeEnum;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* @author songminsgong
|
||||
* @since 2022-11-23
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class AppException extends RuntimeException {
|
||||
|
||||
|
@ -2,11 +2,13 @@ package com.ycwl.basic.exception;
|
||||
|
||||
import com.ycwl.basic.enums.BizCodeEnum;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* @author wenshijia
|
||||
* @date 2021年05月25日 22:41
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class BizException extends RuntimeException {
|
||||
|
||||
|
@ -23,14 +23,11 @@ public class FaceBodyFactory {
|
||||
}
|
||||
|
||||
public static IFaceBodyAdapter getAdapter(FaceBodyAdapterType type) {
|
||||
switch (type) {
|
||||
case ALI:
|
||||
return new AliFaceBodyAdapter();
|
||||
case BCE:
|
||||
return new BceFaceBodyAdapter();
|
||||
default:
|
||||
throw new FaceBodyUnsupportedException("不支持的Adapter类型");
|
||||
}
|
||||
return switch (type) {
|
||||
case ALI -> new AliFaceBodyAdapter();
|
||||
case BCE -> new BceFaceBodyAdapter();
|
||||
default -> throw new FaceBodyUnsupportedException("不支持的Adapter类型");
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
@ -29,6 +29,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
@ -62,33 +63,31 @@ public class AliFaceBodyAdapter implements IFaceBodyAdapter {
|
||||
}
|
||||
|
||||
private IRateLimiter getLimiter(LOCK_TYPE type) {
|
||||
switch (type) {
|
||||
case ADD_DB:
|
||||
return addDbLimiters.computeIfAbsent(config.getAccessKeyId(), k -> new FixedRateLimiter(600, TimeUnit.MILLISECONDS));
|
||||
case ADD_ENTITY:
|
||||
return addEntityLimiters.computeIfAbsent(config.getAccessKeyId(), k -> new FixedRateLimiter(600, TimeUnit.MILLISECONDS));
|
||||
case ADD_FACE:
|
||||
return addFaceLimiters.computeIfAbsent(config.getAccessKeyId(), k -> new FixedRateLimiter(600, TimeUnit.MILLISECONDS));
|
||||
case LIST_DB:
|
||||
return listDbLimiters.computeIfAbsent(config.getAccessKeyId(), k -> new FixedRateLimiter(500, TimeUnit.MILLISECONDS));
|
||||
case LIST_FACE:
|
||||
return listFaceLimiters.computeIfAbsent(config.getAccessKeyId(), k -> new FixedRateLimiter(2));
|
||||
case SEARCH_FACE:
|
||||
return searchFaceLimiters.computeIfAbsent(config.getAccessKeyId(), k -> new FixedRateLimiter(200, TimeUnit.MILLISECONDS));
|
||||
case DELETE_DB:
|
||||
return deleteDbLimiters.computeIfAbsent(config.getAccessKeyId(), k -> new FixedRateLimiter(600, TimeUnit.MILLISECONDS));
|
||||
case DELETE_ENTITY:
|
||||
return deleteEntityLimiters.computeIfAbsent(config.getAccessKeyId(), k -> new FixedRateLimiter(600, TimeUnit.MILLISECONDS));
|
||||
default:
|
||||
return new FixedRateLimiter(600, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
return switch (type) {
|
||||
case ADD_DB ->
|
||||
addDbLimiters.computeIfAbsent(config.getAccessKeyId(), k -> new FixedRateLimiter(600, TimeUnit.MILLISECONDS));
|
||||
case ADD_ENTITY ->
|
||||
addEntityLimiters.computeIfAbsent(config.getAccessKeyId(), k -> new FixedRateLimiter(600, TimeUnit.MILLISECONDS));
|
||||
case ADD_FACE ->
|
||||
addFaceLimiters.computeIfAbsent(config.getAccessKeyId(), k -> new FixedRateLimiter(600, TimeUnit.MILLISECONDS));
|
||||
case LIST_DB ->
|
||||
listDbLimiters.computeIfAbsent(config.getAccessKeyId(), k -> new FixedRateLimiter(500, TimeUnit.MILLISECONDS));
|
||||
case LIST_FACE -> listFaceLimiters.computeIfAbsent(config.getAccessKeyId(), k -> new FixedRateLimiter(2));
|
||||
case SEARCH_FACE ->
|
||||
searchFaceLimiters.computeIfAbsent(config.getAccessKeyId(), k -> new FixedRateLimiter(200, TimeUnit.MILLISECONDS));
|
||||
case DELETE_DB ->
|
||||
deleteDbLimiters.computeIfAbsent(config.getAccessKeyId(), k -> new FixedRateLimiter(600, TimeUnit.MILLISECONDS));
|
||||
case DELETE_ENTITY ->
|
||||
deleteEntityLimiters.computeIfAbsent(config.getAccessKeyId(), k -> new FixedRateLimiter(600, TimeUnit.MILLISECONDS));
|
||||
default -> new FixedRateLimiter(600, TimeUnit.MILLISECONDS);
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addFaceDb(String dbName) {
|
||||
IRateLimiter addDbLimiter = getLimiter(LOCK_TYPE.ADD_DB);
|
||||
try (ClientWrapper clientWrapper = getClient()) {
|
||||
IAcsClient client = clientWrapper.getClient();
|
||||
IAcsClient client = clientWrapper.client();
|
||||
CreateFaceDbRequest request = new CreateFaceDbRequest();
|
||||
request.setName(dbName);
|
||||
try {
|
||||
@ -112,7 +111,7 @@ public class AliFaceBodyAdapter implements IFaceBodyAdapter {
|
||||
request.setOrder("asc");
|
||||
request.setLimit(200);
|
||||
try (ClientWrapper clientWrapper = getClient()) {
|
||||
IAcsClient client = clientWrapper.getClient();
|
||||
IAcsClient client = clientWrapper.client();
|
||||
while (true) {
|
||||
ListFaceEntitiesResponse response = client.getAcsResponse(request);
|
||||
if (response.getData().getTotalCount() == 0) {
|
||||
@ -151,7 +150,7 @@ public class AliFaceBodyAdapter implements IFaceBodyAdapter {
|
||||
public List<String> listFaceDb() {
|
||||
ListFaceDbsRequest request = new ListFaceDbsRequest();
|
||||
try (ClientWrapper clientWrapper = getClient()) {
|
||||
IAcsClient client = clientWrapper.getClient();
|
||||
IAcsClient client = clientWrapper.client();
|
||||
ListFaceDbsResponse response = client.getAcsResponse(request);
|
||||
return response.getData().getDbList().stream().map(ListFaceDbsResponse.Data.DbListItem::getName).collect(Collectors.toList());
|
||||
} catch (ClientException e) {
|
||||
@ -168,7 +167,7 @@ public class AliFaceBodyAdapter implements IFaceBodyAdapter {
|
||||
request.setDbName(dbName);
|
||||
request.setEntityId(entityId);
|
||||
try (ClientWrapper clientWrapper = getClient()) {
|
||||
IAcsClient client = clientWrapper.getClient();
|
||||
IAcsClient client = clientWrapper.client();
|
||||
try {
|
||||
addEntityLimiter.acquire();
|
||||
} catch (InterruptedException ignored) {
|
||||
@ -207,7 +206,7 @@ public class AliFaceBodyAdapter implements IFaceBodyAdapter {
|
||||
request.setDbName(dbName);
|
||||
request.setEntityId(entityId);
|
||||
try (ClientWrapper clientWrapper = getClient()) {
|
||||
IAcsClient client = clientWrapper.getClient();
|
||||
IAcsClient client = clientWrapper.client();
|
||||
try {
|
||||
deleteEntityLimiter.acquire();
|
||||
} catch (InterruptedException ignored) {
|
||||
@ -231,16 +230,12 @@ public class AliFaceBodyAdapter implements IFaceBodyAdapter {
|
||||
if (offset != null) {
|
||||
listFaceEntitiesRequest.setOffset(offset);
|
||||
}
|
||||
if (size != null) {
|
||||
listFaceEntitiesRequest.setLimit(size);
|
||||
} else {
|
||||
listFaceEntitiesRequest.setLimit(200);
|
||||
}
|
||||
listFaceEntitiesRequest.setLimit(Objects.requireNonNullElse(size, 200));
|
||||
if (StringUtils.isNotEmpty(prefix)) {
|
||||
listFaceEntitiesRequest.setEntityIdPrefix(prefix);
|
||||
}
|
||||
try (ClientWrapper clientWrapper = getClient()) {
|
||||
IAcsClient client = clientWrapper.getClient();
|
||||
IAcsClient client = clientWrapper.client();
|
||||
try {
|
||||
listFaceLimiter.acquire();
|
||||
} catch (InterruptedException ignored) {
|
||||
@ -260,7 +255,7 @@ public class AliFaceBodyAdapter implements IFaceBodyAdapter {
|
||||
SearchFaceResp resp = new SearchFaceResp();
|
||||
IRateLimiter searchFaceLimiter = getLimiter(LOCK_TYPE.SEARCH_FACE);
|
||||
try (ClientWrapper clientWrapper = getClient()) {
|
||||
IAcsClient client = clientWrapper.getClient();
|
||||
IAcsClient client = clientWrapper.client();
|
||||
SearchFaceRequest request = new SearchFaceRequest();
|
||||
request.setDbName(dbName);
|
||||
request.setImageUrl(faceUrl);
|
||||
@ -276,7 +271,7 @@ public class AliFaceBodyAdapter implements IFaceBodyAdapter {
|
||||
resp.setOriginalFaceScore(0f);
|
||||
return resp;
|
||||
}
|
||||
SearchFaceResponse.Data.MatchListItem matchItem = matchList.get(0);
|
||||
SearchFaceResponse.Data.MatchListItem matchItem = matchList.getFirst();
|
||||
resp.setOriginalFaceScore(matchItem.getQualitieScore());
|
||||
resp.setResult(matchItem.getFaceItems().stream().map(item -> {
|
||||
SearchFaceResultItem resultItem = new SearchFaceResultItem();
|
||||
@ -287,7 +282,7 @@ public class AliFaceBodyAdapter implements IFaceBodyAdapter {
|
||||
return resultItem;
|
||||
}).collect(Collectors.toList()));
|
||||
if (!resp.getResult().isEmpty()) {
|
||||
resp.setFirstMatchRate(resp.getResult().get(0).getScore());
|
||||
resp.setFirstMatchRate(resp.getResult().getFirst().getScore());
|
||||
}
|
||||
return resp;
|
||||
} catch (ClientException e) {
|
||||
@ -304,13 +299,7 @@ public class AliFaceBodyAdapter implements IFaceBodyAdapter {
|
||||
return new ClientWrapper(client);
|
||||
}
|
||||
|
||||
@Getter
|
||||
public static class ClientWrapper implements AutoCloseable {
|
||||
private final IAcsClient client;
|
||||
|
||||
public ClientWrapper(IAcsClient client) {
|
||||
this.client = client;
|
||||
}
|
||||
public record ClientWrapper(IAcsClient client) implements AutoCloseable {
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
@ -319,7 +308,6 @@ public class AliFaceBodyAdapter implements IFaceBodyAdapter {
|
||||
}
|
||||
client.shutdown();
|
||||
}
|
||||
|
||||
}
|
||||
protected enum LOCK_TYPE {
|
||||
ADD_DB,
|
||||
|
@ -304,7 +304,7 @@ public class BceFaceBodyAdapter implements IFaceBodyAdapter {
|
||||
}
|
||||
resp.setResult(result);
|
||||
if (!result.isEmpty()) {
|
||||
resp.setFirstMatchRate(result.get(0).getScore());
|
||||
resp.setFirstMatchRate(result.getFirst().getScore());
|
||||
}
|
||||
return resp;
|
||||
} else {
|
||||
@ -334,26 +334,25 @@ public class BceFaceBodyAdapter implements IFaceBodyAdapter {
|
||||
}
|
||||
|
||||
private IRateLimiter getLimiter(LOCK_TYPE type) {
|
||||
switch (type) {
|
||||
case ADD_DB:
|
||||
return addDbLimiters.computeIfAbsent(config.getAppId(), k -> new FixedRateLimiter(105, TimeUnit.MILLISECONDS));
|
||||
case ADD_FACE:
|
||||
return addFaceLimiters.computeIfAbsent(config.getAppId(), k -> new FixedRateLimiter(config.getAddQps()));
|
||||
case LIST_DB:
|
||||
return listDbLimiters.computeIfAbsent(config.getAppId(), k -> new FixedRateLimiter(105, TimeUnit.MILLISECONDS));
|
||||
case LIST_FACE:
|
||||
return listFaceLimiters.computeIfAbsent(config.getAppId(), k -> new FixedRateLimiter(105, TimeUnit.MILLISECONDS));
|
||||
case SEARCH_FACE:
|
||||
return searchFaceLimiters.computeIfAbsent(config.getAppId(), k -> new FixedRateLimiter(config.getSearchQps()));
|
||||
case DELETE_DB:
|
||||
return deleteDbLimiters.computeIfAbsent(config.getAppId(), k -> new FixedRateLimiter(105, TimeUnit.MILLISECONDS));
|
||||
case DELETE_ENTITY:
|
||||
return deleteEntityLimiters.computeIfAbsent(config.getAppId(), k -> new FixedRateLimiter(105, TimeUnit.MILLISECONDS));
|
||||
case DELETE_FACE:
|
||||
return deleteFaceLimiters.computeIfAbsent(config.getAppId(), k -> new FixedRateLimiter(105, TimeUnit.MILLISECONDS));
|
||||
default:
|
||||
return new FixedRateLimiter(500, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
return switch (type) {
|
||||
case ADD_DB ->
|
||||
addDbLimiters.computeIfAbsent(config.getAppId(), k -> new FixedRateLimiter(105, TimeUnit.MILLISECONDS));
|
||||
case ADD_FACE ->
|
||||
addFaceLimiters.computeIfAbsent(config.getAppId(), k -> new FixedRateLimiter(config.getAddQps()));
|
||||
case LIST_DB ->
|
||||
listDbLimiters.computeIfAbsent(config.getAppId(), k -> new FixedRateLimiter(105, TimeUnit.MILLISECONDS));
|
||||
case LIST_FACE ->
|
||||
listFaceLimiters.computeIfAbsent(config.getAppId(), k -> new FixedRateLimiter(105, TimeUnit.MILLISECONDS));
|
||||
case SEARCH_FACE ->
|
||||
searchFaceLimiters.computeIfAbsent(config.getAppId(), k -> new FixedRateLimiter(config.getSearchQps()));
|
||||
case DELETE_DB ->
|
||||
deleteDbLimiters.computeIfAbsent(config.getAppId(), k -> new FixedRateLimiter(105, TimeUnit.MILLISECONDS));
|
||||
case DELETE_ENTITY ->
|
||||
deleteEntityLimiters.computeIfAbsent(config.getAppId(), k -> new FixedRateLimiter(105, TimeUnit.MILLISECONDS));
|
||||
case DELETE_FACE ->
|
||||
deleteFaceLimiters.computeIfAbsent(config.getAppId(), k -> new FixedRateLimiter(105, TimeUnit.MILLISECONDS));
|
||||
default -> new FixedRateLimiter(500, TimeUnit.MILLISECONDS);
|
||||
};
|
||||
}
|
||||
|
||||
protected enum LOCK_TYPE {
|
||||
|
@ -16,15 +16,11 @@ public class ImageWatermarkFactory {
|
||||
return get(type);
|
||||
}
|
||||
public static IOperator get(ImageWatermarkOperatorEnum type) {
|
||||
switch (type) {
|
||||
case WATERMARK:
|
||||
return new DefaultImageWatermarkOperator();
|
||||
case NORMAL:
|
||||
return new NormalWatermarkOperator();
|
||||
case LEICA:
|
||||
return new LeicaWatermarkOperator();
|
||||
default:
|
||||
throw new ImageWatermarkUnsupportedException("不支持的类型"+type.name());
|
||||
}
|
||||
return switch (type) {
|
||||
case WATERMARK -> new DefaultImageWatermarkOperator();
|
||||
case NORMAL -> new NormalWatermarkOperator();
|
||||
case LEICA -> new LeicaWatermarkOperator();
|
||||
default -> throw new ImageWatermarkUnsupportedException("不支持的类型" + type.name());
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -106,13 +106,13 @@ public class LeicaWatermarkOperator implements IOperator {
|
||||
int dtLineHeight = datetimeFontMetrics.getHeight();
|
||||
int scenicLineWidth = scenicFontMetrics.stringWidth(info.getScenicLine());
|
||||
int datetimeLineWidth = scenicFontMetrics.stringWidth(info.getDatetimeLine());
|
||||
g2d.drawImage(qrcodeImage, newImage.getWidth() + EXTRA_BORDER_PX - OFFSET_X - newQrcodeWidth - QRCODE_OFFSET_X - Math.max(scenicLineWidth, datetimeLineWidth), EXTRA_BORDER_PX + baseImage.getHeight() + + OFFSET_Y, newQrcodeWidth, newQrcodeHeight, null);
|
||||
g2d.drawImage(qrcodeImage, newImage.getWidth() + EXTRA_BORDER_PX - OFFSET_X - newQrcodeWidth - QRCODE_OFFSET_X - Math.max(scenicLineWidth, datetimeLineWidth), EXTRA_BORDER_PX + baseImage.getHeight() + OFFSET_Y, newQrcodeWidth, newQrcodeHeight, null);
|
||||
g2d.setFont(scenicFont);
|
||||
g2d.setColor(scenicColor);
|
||||
g2d.drawString(info.getScenicLine(), newImage.getWidth() + EXTRA_BORDER_PX - OFFSET_X - Math.max(scenicLineWidth, datetimeLineWidth), EXTRA_BORDER_PX + baseImage.getHeight() + + OFFSET_Y + scenicLineHeight + scenicLineHeight * FONT_GLOBAL_OFFSET_PERCENT);
|
||||
g2d.drawString(info.getScenicLine(), newImage.getWidth() + EXTRA_BORDER_PX - OFFSET_X - Math.max(scenicLineWidth, datetimeLineWidth), EXTRA_BORDER_PX + baseImage.getHeight() + OFFSET_Y + scenicLineHeight + scenicLineHeight * FONT_GLOBAL_OFFSET_PERCENT);
|
||||
g2d.setFont(datetimeFont);
|
||||
g2d.setColor(datetimeColor);
|
||||
g2d.drawString(info.getDatetimeLine(), newImage.getWidth() + EXTRA_BORDER_PX - OFFSET_X - Math.max(scenicLineWidth, datetimeLineWidth), EXTRA_BORDER_PX + baseImage.getHeight() + + OFFSET_Y + scenicLineHeight + dtLineHeight + dtLineHeight * FONT_GLOBAL_OFFSET_PERCENT);
|
||||
g2d.drawString(info.getDatetimeLine(), newImage.getWidth() + EXTRA_BORDER_PX - OFFSET_X - Math.max(scenicLineWidth, datetimeLineWidth), EXTRA_BORDER_PX + baseImage.getHeight() + OFFSET_Y + scenicLineHeight + dtLineHeight + dtLineHeight * FONT_GLOBAL_OFFSET_PERCENT);
|
||||
String fileName = info.getWatermarkedFile().getName();
|
||||
String formatName = "jpg"; // 默认格式为 jpg
|
||||
if (fileName.endsWith(".png")) {
|
||||
|
@ -7,6 +7,7 @@ import com.ycwl.basic.constant.PermissionConstant;
|
||||
import com.ycwl.basic.constant.RequestConstant;
|
||||
import com.ycwl.basic.exception.CheckTokenException;
|
||||
import com.ycwl.basic.exception.MissTokenException;
|
||||
import com.ycwl.basic.exception.PermissionException;
|
||||
import com.ycwl.basic.model.jwt.JwtInfo;
|
||||
import com.ycwl.basic.utils.JwtTokenUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -33,12 +34,11 @@ public class AuthInterceptor implements HandlerInterceptor {
|
||||
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||
if (!(handler instanceof HandlerMethod)) {
|
||||
if (!(handler instanceof HandlerMethod handlerMethod)) {
|
||||
return true;
|
||||
}
|
||||
String requestURI = request.getRequestURI();
|
||||
|
||||
HandlerMethod handlerMethod = (HandlerMethod) handler;
|
||||
// 获取类上面的注解
|
||||
IgnoreToken ignoreClassToken = handlerMethod.getBeanType().getAnnotation(IgnoreToken.class);
|
||||
// 获取方法上的注解
|
||||
|
@ -6,6 +6,7 @@ import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@ -18,6 +19,7 @@ import java.time.LocalDateTime;
|
||||
@ToString
|
||||
public class JwtInfo implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 5452605590172369563L;
|
||||
|
||||
/**
|
||||
|
@ -4,6 +4,7 @@ import com.ycwl.basic.model.common.BaseQueryParameterReq;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
@ -12,6 +13,7 @@ import java.util.Date;
|
||||
* @Author:longbinbin
|
||||
* @Date:2024/11/29 16:33
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@ApiModel(value = "移动端订单查询对象")
|
||||
public class OrderAppPageReq extends BaseQueryParameterReq {
|
||||
|
@ -4,7 +4,9 @@ import com.ycwl.basic.model.common.BaseQueryParameterReq;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@ApiModel(value = "后台管理人员请求VO")
|
||||
public class AdminUserListReqVO extends BaseQueryParameterReq {
|
||||
|
@ -5,7 +5,7 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@ApiModel(value = "")
|
||||
@ApiModel()
|
||||
public class UpdatePasswordReqVO {
|
||||
@ApiModelProperty(value = "id",hidden = true)
|
||||
private String id;
|
||||
|
@ -6,6 +6,7 @@ import com.ycwl.basic.model.common.BaseQueryParameterReq;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@ -13,6 +14,7 @@ import java.util.Date;
|
||||
* @Author:longbinbin
|
||||
* @Date:2024/12/12 10:00
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@ApiModel("查询推客记录请求参数")
|
||||
public class BrokerRecordReqQuery extends BaseQueryParameterReq {
|
||||
|
@ -5,6 +5,7 @@ import com.ycwl.basic.model.common.BaseQueryParameterReq;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@ -12,6 +13,7 @@ import java.util.Date;
|
||||
* @Author:longbinbin
|
||||
* @Date:2024/11/29 14:29
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@ApiModel("查询推客列表请求参数")
|
||||
public class BrokerReqQuery extends BaseQueryParameterReq {
|
||||
|
@ -5,6 +5,7 @@ import com.ycwl.basic.model.common.BaseQueryParameterReq;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@ -12,6 +13,7 @@ import java.util.Date;
|
||||
* @Author:longbinbin
|
||||
* @Date:2024/11/29 14:53
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@ApiModel("设备查询参数")
|
||||
public class DeviceReqQuery extends BaseQueryParameterReq {
|
||||
|
@ -8,6 +8,6 @@ public class DeviceSortRequest {
|
||||
@ApiModelProperty(value = "被操作模板的ID", required = true)
|
||||
private Long deviceId;
|
||||
|
||||
@ApiModelProperty(value = "排在其后的模板ID", required = false)
|
||||
@ApiModelProperty(value = "排在其后的模板ID")
|
||||
private Long afterDeviceId;
|
||||
}
|
@ -5,6 +5,7 @@ import com.ycwl.basic.model.common.BaseQueryParameterReq;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
@ -13,6 +14,7 @@ import java.util.Date;
|
||||
* @Author:longbinbin
|
||||
* @Date:2024/11/29 15:16
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@ApiModel("人脸查询参数")
|
||||
public class FaceReqQuery extends BaseQueryParameterReq {
|
||||
|
@ -7,6 +7,7 @@ import com.ycwl.basic.model.common.BaseQueryParameterReq;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@ -14,6 +15,7 @@ import java.util.Date;
|
||||
* @Author:longbinbin
|
||||
* @Date:2024/11/29 15:40
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@ApiModel("人脸样本查询参数")
|
||||
public class FaceSampleReqQuery extends BaseQueryParameterReq {
|
||||
|
@ -6,6 +6,7 @@ import com.ycwl.basic.model.common.BaseQueryParameterReq;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@ -13,6 +14,7 @@ import java.util.Date;
|
||||
* @Author:longbinbin
|
||||
* @Date:2024/11/29 15:59
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@ApiModel("查询用户列表请求参数")
|
||||
public class MemberReqQuery extends BaseQueryParameterReq {
|
||||
|
@ -7,6 +7,7 @@ import com.ycwl.basic.model.common.BaseQueryParameterReq;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
@ -15,6 +16,7 @@ import java.util.Date;
|
||||
* @Author:longbinbin
|
||||
* @Date:2024/11/29 16:33
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@ApiModel(value = "订单查询对象")
|
||||
public class OrderReqQuery extends BaseQueryParameterReq {
|
||||
|
@ -6,12 +6,14 @@ import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@TableName("permission")
|
||||
public class PermissionEntity implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
|
@ -6,6 +6,7 @@ import com.ycwl.basic.model.common.BaseQueryParameterReq;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
@ -15,6 +16,7 @@ import java.util.Date;
|
||||
* @Date:2024/11/29 17:24
|
||||
* 渲染机管理表
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@ApiModel("渲染机列表查询参数")
|
||||
public class RenderWorkerReqQuery extends BaseQueryParameterReq {
|
||||
|
@ -4,7 +4,9 @@ import com.ycwl.basic.model.common.BaseQueryParameterReq;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@ApiModel(value = "角色请求列表VO")
|
||||
public class RoleListReqVO extends BaseQueryParameterReq {
|
||||
|
@ -8,6 +8,6 @@ public class TemplateSortRequest {
|
||||
@ApiModelProperty(value = "被操作模板的ID", required = true)
|
||||
private Long templateId;
|
||||
|
||||
@ApiModelProperty(value = "排在其后的模板ID", required = false)
|
||||
@ApiModelProperty(value = "排在其后的模板ID")
|
||||
private Long afterTemplateId;
|
||||
}
|
@ -4,6 +4,7 @@ import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
@ -20,6 +21,7 @@ public class UniqueId implements Serializable {
|
||||
* 固定 + 时间戳 + 工作机器ID + 数据中心ID + 序列号
|
||||
*/
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 8632670752020316524L;
|
||||
|
||||
/**
|
||||
|
@ -1,24 +0,0 @@
|
||||
package com.ycwl.basic.model.wx;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 微信获取token对象
|
||||
* @author: chenxi
|
||||
* @date: 2021/8/5 20:50
|
||||
*/
|
||||
@Data
|
||||
public class WechatAccessTokenVO extends WechatBaseVO{
|
||||
|
||||
/**
|
||||
* 微信access_token,由于微信接口返回数据,此处无法保证驼峰命名
|
||||
*/
|
||||
private String access_token;
|
||||
|
||||
/**
|
||||
* 过期时间,单位秒
|
||||
*/
|
||||
private Integer expires_in;
|
||||
|
||||
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
package com.ycwl.basic.model.wx;
|
||||
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@ -16,7 +15,7 @@ import java.util.Date;
|
||||
*/
|
||||
@Data
|
||||
@Slf4j
|
||||
public class WxchatCallbackSuccessData {
|
||||
public class WechatCallbackSuccessData {
|
||||
|
||||
/**
|
||||
* 商户订单号
|
||||
@ -58,12 +57,4 @@ public class WxchatCallbackSuccessData {
|
||||
private BigDecimal totalMoney;
|
||||
|
||||
|
||||
public Date getSuccessTime() {
|
||||
return successTime;
|
||||
}
|
||||
|
||||
public void setSuccessTime(String successTime) {
|
||||
// Hutool工具包的方法,自动识别一些常用格式的日期字符串
|
||||
this.successTime = DateUtil.parse(successTime);
|
||||
}
|
||||
}
|
@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
@ -17,6 +18,7 @@ import java.io.Serializable;
|
||||
@Accessors(chain = true)
|
||||
public class WxPayRespVO implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
private boolean needPay = true;
|
||||
/**
|
||||
|
@ -10,14 +10,11 @@ import java.util.Map;
|
||||
|
||||
public class NotifyFactory {
|
||||
public static INotifyAdapter get(NotifyType type) {
|
||||
switch (type) {
|
||||
case SERVER_CHAN:
|
||||
return new ServerChanNotifyAdapter();
|
||||
case WX_MP_SRV:
|
||||
return new WxMpSrvNotifyAdapter();
|
||||
default:
|
||||
throw new RuntimeException("不支持的通知类型");
|
||||
}
|
||||
return switch (type) {
|
||||
case SERVER_CHAN -> new ServerChanNotifyAdapter();
|
||||
case WX_MP_SRV -> new WxMpSrvNotifyAdapter();
|
||||
default -> throw new RuntimeException("不支持的通知类型");
|
||||
};
|
||||
}
|
||||
|
||||
public static INotifyAdapter get(NotifyType type, Map<String, String> config) {
|
||||
|
@ -8,6 +8,7 @@ import com.ycwl.basic.pay.exceptions.PayUnsupportedException;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
public class PayFactory {
|
||||
|
||||
@ -22,12 +23,10 @@ public class PayFactory {
|
||||
}
|
||||
|
||||
public static IPayAdapter getAdapter(PayAdapterType type) {
|
||||
switch (type) {
|
||||
case WX_MP_PAY:
|
||||
if (Objects.requireNonNull(type) == PayAdapterType.WX_MP_PAY) {
|
||||
return new WxMpPayAdapter();
|
||||
default:
|
||||
throw new PayUnsupportedException("不支持的Adapter类型");
|
||||
}
|
||||
throw new PayUnsupportedException("不支持的Adapter类型");
|
||||
}
|
||||
|
||||
protected static Map<String, IPayAdapter> namedAdapter = new HashMap<>();
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.ycwl.basic.pay.adapter;
|
||||
|
||||
import cn.hutool.core.codec.Base64;
|
||||
import com.wechat.pay.java.core.Config;
|
||||
import com.wechat.pay.java.core.RSAAutoCertificateConfig;
|
||||
import com.wechat.pay.java.core.RSAPublicKeyConfig;
|
||||
@ -32,7 +33,6 @@ import com.ycwl.basic.pay.entity.RefundOrderResponse;
|
||||
import com.ycwl.basic.pay.entity.WxMpPayConfig;
|
||||
import com.ycwl.basic.pay.exceptions.PayWrongConfigException;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.util.Base64Utils;
|
||||
|
||||
import jakarta.servlet.ServletInputStream;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
@ -161,7 +161,7 @@ public class WxMpPayAdapter implements IPayAdapter {
|
||||
@Override
|
||||
public PayResponse handleCallback(HttpServletRequest request) throws IOException {
|
||||
ServletInputStream inputStream = request.getInputStream();
|
||||
StringBuffer body = new StringBuffer();
|
||||
StringBuilder body = new StringBuilder();
|
||||
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
|
||||
String s;
|
||||
// 读取回调请求体
|
||||
@ -277,7 +277,7 @@ public class WxMpPayAdapter implements IPayAdapter {
|
||||
@Override
|
||||
public RefundResponse handleRefundCallback(HttpServletRequest request) throws IOException {
|
||||
ServletInputStream inputStream = request.getInputStream();
|
||||
StringBuffer body = new StringBuffer();
|
||||
StringBuilder body = new StringBuilder();
|
||||
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
|
||||
String s;
|
||||
// 读取回调请求体
|
||||
@ -363,6 +363,6 @@ public class WxMpPayAdapter implements IPayAdapter {
|
||||
Signature sign = Signature.getInstance("SHA256withRSA");
|
||||
sign.initSign(merchantPrivateKey);
|
||||
sign.update(signatureStr.getBytes(StandardCharsets.UTF_8));
|
||||
return Base64Utils.encodeToString(sign.sign());
|
||||
return Base64.encode(sign.sign());
|
||||
}
|
||||
}
|
||||
|
@ -1,20 +1,16 @@
|
||||
package com.ycwl.basic.pay.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public enum PayAdapterType {
|
||||
WX_MP_PAY("WX_MP_PAY"),
|
||||
;
|
||||
|
||||
private String type;
|
||||
private final String type;
|
||||
|
||||
PayAdapterType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ public class FeiETicketPrinter {
|
||||
|
||||
HttpRequest post = HttpUtil.createPost(URL);
|
||||
post.header("Content-Type", "application/x-www-form-urlencoded");
|
||||
Map<String, Object> body = new HashMap<String, Object>();
|
||||
Map<String, Object> body = new HashMap<>();
|
||||
body.put("user",USER);
|
||||
String STIME = String.valueOf(System.currentTimeMillis()/1000);
|
||||
body.put("stime",STIME);
|
||||
|
@ -45,12 +45,10 @@ public class ProfitSharingBiz {
|
||||
userAmount = amount.multiply(user.getRealRate()).divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_DOWN);
|
||||
wxAmount = amount.multiply(user.getWxRate()).divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_DOWN);
|
||||
manualAmount = userAmount.subtract(wxAmount);
|
||||
} else if (user.getRateMode() == 3) { // 固定抽成
|
||||
} else { // 固定抽成
|
||||
userAmount = user.getRealRate();
|
||||
wxAmount = user.getWxRate();
|
||||
manualAmount = userAmount.subtract(wxAmount);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
ProfitSharingRecord record = new ProfitSharingRecord();
|
||||
record.setScenicId(scenicId);
|
||||
@ -77,13 +75,10 @@ public class ProfitSharingBiz {
|
||||
BigDecimal userAmount;
|
||||
BigDecimal wxAmount;
|
||||
BigDecimal manualAmount;
|
||||
if (user.getRateMode() == 2) { // 扣除固定抽成后的动态比例
|
||||
// 扣除固定抽成后的动态比例
|
||||
userAmount = mode2RemainAmount.multiply(user.getRealRate()).divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_DOWN);
|
||||
wxAmount = mode2RemainAmount.multiply(user.getWxRate()).divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_DOWN);
|
||||
manualAmount = userAmount.subtract(wxAmount);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
ProfitSharingRecord record = new ProfitSharingRecord();
|
||||
record.setScenicId(scenicId);
|
||||
record.setOrderId(orderId);
|
||||
@ -109,13 +104,10 @@ public class ProfitSharingBiz {
|
||||
BigDecimal userAmount;
|
||||
BigDecimal wxAmount;
|
||||
BigDecimal manualAmount;
|
||||
if (user.getRateMode() == 4) { // 扣除其他所有类型抽成后的动态比例
|
||||
// 扣除其他所有类型抽成后的动态比例
|
||||
userAmount = mode4RemainAmount.multiply(user.getRealRate()).divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_DOWN);
|
||||
wxAmount = mode4RemainAmount.multiply(user.getWxRate()).divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_DOWN);
|
||||
manualAmount = userAmount.subtract(wxAmount);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
ProfitSharingRecord record = new ProfitSharingRecord();
|
||||
record.setScenicId(scenicId);
|
||||
record.setOrderId(orderId);
|
||||
|
@ -5,7 +5,7 @@ import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class ProfitSharingConfigVO extends ProfitSharingConfig {
|
||||
private String scenicName;
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ public class ProfitSharingRecordServiceImpl implements ProfitSharingRecordServic
|
||||
map.put(item.getUserName(), item);
|
||||
});
|
||||
ProfitSharingTableRecordVO vo = new ProfitSharingTableRecordVO();
|
||||
ProfitSharingRecordRespVO recordRespVO = value.get(0);
|
||||
ProfitSharingRecordRespVO recordRespVO = value.getFirst();
|
||||
vo.setOrderId(recordRespVO.getOrderId());
|
||||
vo.setScenicId(recordRespVO.getScenicId());
|
||||
vo.setScenicName(recordRespVO.getScenicName());
|
||||
|
@ -1,11 +1,10 @@
|
||||
package com.ycwl.basic.service.mobile;
|
||||
|
||||
import com.ycwl.basic.model.wx.WXPayOrderReqVO;
|
||||
import com.ycwl.basic.model.wx.WxchatCallbackSuccessData;
|
||||
import com.ycwl.basic.model.wx.WechatCallbackSuccessData;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import java.io.IOException;
|
||||
import java.security.GeneralSecurityException;
|
||||
import java.util.Map;
|
||||
|
||||
public interface WxPayService {
|
||||
@ -26,7 +25,7 @@ public interface WxPayService {
|
||||
/**
|
||||
* 微信支付结果查询
|
||||
*/
|
||||
WxchatCallbackSuccessData queryPay(Long orderId);
|
||||
WechatCallbackSuccessData queryPay(Long orderId);
|
||||
|
||||
/**
|
||||
* 订单退款
|
||||
|
@ -53,6 +53,7 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@ -143,7 +144,7 @@ public class GoodsServiceImpl implements GoodsService {
|
||||
return true;
|
||||
}).map(type -> {
|
||||
GoodsPageVO goodsPageVO = new GoodsPageVO();
|
||||
goodsPageVO.setTemplateCoverUrl(goods.get(0).getUrl());
|
||||
goodsPageVO.setTemplateCoverUrl(goods.getFirst().getUrl());
|
||||
goodsPageVO.setFaceId(faceId);
|
||||
if (type == 1) {
|
||||
goodsPageVO.setGoodsName("录像集");
|
||||
@ -182,7 +183,7 @@ public class GoodsServiceImpl implements GoodsService {
|
||||
List<SourceRespVO> list = sourceMapper.listUser(sourceReqQuery);
|
||||
List<GoodsDetailVO> goodsDetailVOList = new ArrayList<>();
|
||||
|
||||
String goodsNamePrefix = "";
|
||||
String goodsNamePrefix;
|
||||
if (sourceType == 1) {
|
||||
goodsNamePrefix = "录像";
|
||||
} else if (sourceType == 2) {
|
||||
@ -209,14 +210,14 @@ public class GoodsServiceImpl implements GoodsService {
|
||||
goodsDetailVO.setIsBuy(sourceRespVO.getIsBuy());
|
||||
if (sourceRespVO.getVideoUrl() != null) {
|
||||
try {
|
||||
URL url = new URL(sourceRespVO.getVideoUrl());
|
||||
URI url = URI.create(sourceRespVO.getVideoUrl());
|
||||
if (StringUtils.startsWith(url.getHost(), "100.64.")) {
|
||||
// 内网地址,需要代理
|
||||
goodsDetailVO.setVideoUrl("https://zhentuai.com/proxy?url=" + sourceRespVO.getVideoUrl());
|
||||
} else {
|
||||
goodsDetailVO.setVideoUrl(sourceRespVO.getVideoUrl());
|
||||
}
|
||||
} catch (MalformedURLException e) {
|
||||
} catch (IllegalArgumentException e) {
|
||||
log.warn("url地址解析异常:{}", sourceRespVO.getVideoUrl(), e);
|
||||
goodsDetailVO.setVideoUrl(sourceRespVO.getVideoUrl());
|
||||
}
|
||||
@ -361,14 +362,14 @@ public class GoodsServiceImpl implements GoodsService {
|
||||
.count();
|
||||
response.setCount(finishedTask);
|
||||
if (!notFinishedTasks.isEmpty()) {
|
||||
response.setTemplateId(notFinishedTasks.get(0).getTemplateId());
|
||||
response.setTaskId(notFinishedTasks.get(0).getTaskId());
|
||||
response.setTemplateId(notFinishedTasks.getFirst().getTemplateId());
|
||||
response.setTaskId(notFinishedTasks.getFirst().getTaskId());
|
||||
response.setStatus(2);
|
||||
return response;
|
||||
}
|
||||
// 重查一下
|
||||
taskList = videoMapper.listRelationByFace(userId, faceId);
|
||||
MemberVideoEntity lastVideo = taskList.get(taskList.size() - 1);
|
||||
MemberVideoEntity lastVideo = taskList.getLast();
|
||||
if (null == lastVideo.getVideoId()) {
|
||||
response.setTemplateId(lastVideo.getTemplateId());
|
||||
response.setTaskId(lastVideo.getTaskId());
|
||||
@ -398,7 +399,7 @@ public class GoodsServiceImpl implements GoodsService {
|
||||
response.setStatus(0);
|
||||
return response;
|
||||
}
|
||||
response.setScenicId(taskList.get(0).getScenicId());
|
||||
response.setScenicId(taskList.getFirst().getScenicId());
|
||||
response.setMaxCount(templateRepository.getTemplateListByScenicId(response.getScenicId()).size());
|
||||
List<MemberVideoEntity> notFinishedTasks = taskList.stream()
|
||||
.filter(task -> {
|
||||
@ -420,18 +421,18 @@ public class GoodsServiceImpl implements GoodsService {
|
||||
int faceCutStatus = taskStatusBiz.getFaceCutStatus(faceId);
|
||||
if (Integer.valueOf(0).equals(faceCutStatus)) {
|
||||
if (!notFinishedTasks.isEmpty()) {
|
||||
response.setTemplateId(notFinishedTasks.get(0).getTemplateId());
|
||||
response.setTemplateId(notFinishedTasks.getFirst().getTemplateId());
|
||||
}
|
||||
response.setStatus(2);
|
||||
return response;
|
||||
}
|
||||
if (!notFinishedTasks.isEmpty()) {
|
||||
response.setTemplateId(notFinishedTasks.get(0).getTemplateId());
|
||||
response.setTaskId(notFinishedTasks.get(0).getTaskId());
|
||||
response.setTemplateId(notFinishedTasks.getFirst().getTemplateId());
|
||||
response.setTaskId(notFinishedTasks.getFirst().getTaskId());
|
||||
response.setStatus(2);
|
||||
return response;
|
||||
}
|
||||
MemberVideoEntity lastVideo = taskList.get(taskList.size() - 1);
|
||||
MemberVideoEntity lastVideo = taskList.getLast();
|
||||
response.setTaskId(lastVideo.getTaskId());
|
||||
response.setTemplateId(lastVideo.getTemplateId());
|
||||
response.setVideoId(lastVideo.getVideoId());
|
||||
@ -483,7 +484,7 @@ public class GoodsServiceImpl implements GoodsService {
|
||||
goodsDetailVO.setGoodsId(sourceRespVO.getId());
|
||||
if (sourceRespVO.getVideoUrl() != null) {
|
||||
try {
|
||||
URL url = new URL(sourceRespVO.getVideoUrl());
|
||||
URL url = URI.create(sourceRespVO.getVideoUrl()).toURL();
|
||||
if (StringUtils.startsWith(url.getHost(), "100.64.")) {
|
||||
// 内网地址,需要代理
|
||||
goodsDetailVO.setVideoUrl("https://zhentuai.com/proxy?url=" + sourceRespVO.getVideoUrl());
|
||||
@ -650,7 +651,7 @@ public class GoodsServiceImpl implements GoodsService {
|
||||
ImageWatermarkOperatorEnum type = ImageWatermarkOperatorEnum.getByCode(scenicConfig.getWatermarkType());
|
||||
if (type != null) {
|
||||
IStorageAdapter adapter;
|
||||
if (scenicConfig != null && scenicConfig.getStoreType() != null) {
|
||||
if (scenicConfig.getStoreType() != null) {
|
||||
adapter = StorageFactory.get(scenicConfig.getStoreType());
|
||||
adapter.loadConfig(JSONObject.parseObject(scenicConfig.getStoreConfigJson(), Map.class));
|
||||
} else {
|
||||
|
@ -15,7 +15,7 @@ import com.ycwl.basic.model.pc.order.entity.OrderEntity;
|
||||
import com.ycwl.basic.model.pc.order.req.OrderUpdateReq;
|
||||
import com.ycwl.basic.model.pc.payment.entity.PaymentEntity;
|
||||
import com.ycwl.basic.model.wx.WXPayOrderReqVO;
|
||||
import com.ycwl.basic.model.wx.WxchatCallbackSuccessData;
|
||||
import com.ycwl.basic.model.wx.WechatCallbackSuccessData;
|
||||
import com.ycwl.basic.pay.adapter.IPayAdapter;
|
||||
import com.ycwl.basic.pay.entity.CancelOrderRequest;
|
||||
import com.ycwl.basic.pay.entity.CreateOrderRequest;
|
||||
@ -116,7 +116,7 @@ public class WxPayServiceImpl implements WxPayService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxchatCallbackSuccessData queryPay(Long orderId) {
|
||||
public WechatCallbackSuccessData queryPay(Long orderId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -144,10 +144,10 @@ public class DeviceServiceImpl implements DeviceService {
|
||||
item.setSort(sortNum.addAndGet(1));
|
||||
}
|
||||
Optional<DeviceEntity> templateOptional = scenicDeviceList.stream().filter(item -> item.getId().equals(deviceId)).findAny();
|
||||
Optional<DeviceEntity> afterTemplateOptional = scenicDeviceList.stream().filter(item -> item.getId().equals(afterDeviceId)).findAny();
|
||||
if (!templateOptional.isPresent()) {
|
||||
if (templateOptional.isEmpty()) {
|
||||
return ApiResponse.fail("设备不存在");
|
||||
}
|
||||
Optional<DeviceEntity> afterTemplateOptional = scenicDeviceList.stream().filter(item -> item.getId().equals(afterDeviceId)).findAny();
|
||||
if (afterTemplateOptional.isPresent()) {
|
||||
DeviceEntity afterTemplate = afterTemplateOptional.get();
|
||||
Integer newSort = afterTemplate.getSort();
|
||||
|
@ -36,11 +36,13 @@ public class DeviceStatsServiceImpl implements DeviceStatsService {
|
||||
List<ScenicDeviceStatsResp> data = mapper.countCachedStatsByScenicId(scenicId, start, end);
|
||||
resp.setData(data);
|
||||
}
|
||||
resp.getData().stream().mapToInt(ScenicDeviceStatsResp::getCount).max().ifPresent((max) -> {
|
||||
resp.getData().forEach(item -> {
|
||||
item.setRate(BigDecimal.valueOf(item.getCount()).divide(BigDecimal.valueOf(max), 6, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)));
|
||||
});
|
||||
});
|
||||
resp.getData().stream()
|
||||
.mapToInt(ScenicDeviceStatsResp::getCount).max()
|
||||
.ifPresent((max) -> resp.getData()
|
||||
.forEach(item -> item.setRate(
|
||||
BigDecimal.valueOf(item.getCount()).divide(BigDecimal.valueOf(max), 6, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)))
|
||||
)
|
||||
);
|
||||
return resp;
|
||||
}
|
||||
}
|
||||
|
@ -153,7 +153,7 @@ public class FaceServiceImpl implements FaceService {
|
||||
String filePath = StorageUtil.joinPath(USER_FACE, DateUtil.format(new Date(),"yyyy-MM-dd"));
|
||||
String originalFilename = file.getOriginalFilename();
|
||||
String suffix = originalFilename.split("\\.", 2)[1];
|
||||
String fileName = UUID.randomUUID().toString() + "." + suffix;
|
||||
String fileName = UUID.randomUUID() + "." + suffix;
|
||||
String faceUrl = adapter.uploadFile(file, filePath, fileName);
|
||||
Long newFaceId = SnowFlakeUtil.getLongId();
|
||||
Long oldFaceId = null;
|
||||
@ -248,7 +248,7 @@ public class FaceServiceImpl implements FaceService {
|
||||
if (scenicConfig != null && scenicConfig.getFaceDetectHelperThreshold() != null && scenicConfig.getFaceDetectHelperThreshold() > 0) {
|
||||
if (scenicDbSearchResult.getSampleListIds().size() < scenicConfig.getFaceDetectHelperThreshold()) {
|
||||
// 补救逻辑
|
||||
Long resultItem = scenicDbSearchResult.getSampleListIds().get(0);
|
||||
Long resultItem = scenicDbSearchResult.getSampleListIds().getFirst();
|
||||
FaceSampleEntity faceSample = faceRepository.getFaceSample(resultItem);
|
||||
if (faceSample != null) {
|
||||
// 以这个结果为人脸库的匹配结果
|
||||
@ -327,24 +327,24 @@ public class FaceServiceImpl implements FaceService {
|
||||
@Override
|
||||
public List<ContentPageVO> faceContentList(Long faceId) {
|
||||
FaceRespVO faceRespVO = faceMapper.getById(faceId);
|
||||
Long userId = faceRespVO.getMemberId();
|
||||
if (faceRespVO == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
Long userId = faceRespVO.getMemberId();
|
||||
List<ContentPageVO> contentList = templateMapper.listFor(faceRespVO.getScenicId());
|
||||
contentList.forEach(contentPageVO -> {
|
||||
List<MemberVideoEntity> memberVideoEntityList = videoMapper.userFaceTemplateVideo(userId, faceId, contentPageVO.getTemplateId());
|
||||
contentPageVO.setGoodsType(0);
|
||||
contentPageVO.setContentType(1);
|
||||
if (!memberVideoEntityList.isEmpty()) {
|
||||
contentPageVO.setIsBuy(memberVideoEntityList.get(0).getIsBuy());
|
||||
contentPageVO.setContentId(memberVideoEntityList.get(0).getVideoId());
|
||||
contentPageVO.setIsBuy(memberVideoEntityList.getFirst().getIsBuy());
|
||||
contentPageVO.setContentId(memberVideoEntityList.getFirst().getVideoId());
|
||||
VideoEntity video = videoRepository.getVideo(contentPageVO.getContentId());
|
||||
if (video != null) {
|
||||
contentPageVO.setDuration(video.getDuration());
|
||||
contentPageVO.setLockType(-1);
|
||||
} else {
|
||||
TaskEntity taskById = videoTaskRepository.getTaskById(memberVideoEntityList.get(0).getTaskId());
|
||||
TaskEntity taskById = videoTaskRepository.getTaskById(memberVideoEntityList.getFirst().getTaskId());
|
||||
if (taskById == null) {
|
||||
contentPageVO.setLockType(0);
|
||||
} else if (taskById.getStatus() == 3) {
|
||||
@ -422,11 +422,11 @@ public class FaceServiceImpl implements FaceService {
|
||||
if (type == 1) {
|
||||
sourceVideoContent.setSourceType(1);
|
||||
sourceVideoContent.setLockType(-1);
|
||||
sourceVideoContent.setTemplateCoverUrl(list.get(0).getUrl());
|
||||
sourceVideoContent.setTemplateCoverUrl(list.getFirst().getUrl());
|
||||
} else {
|
||||
sourceImageContent.setSourceType(2);
|
||||
sourceImageContent.setLockType(-1);
|
||||
sourceImageContent.setTemplateCoverUrl(list.get(0).getUrl());
|
||||
sourceImageContent.setTemplateCoverUrl(list.getFirst().getUrl());
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -118,15 +118,15 @@ public class OrderServiceImpl implements OrderService {
|
||||
OrderAppRespVO orderAppRespVO = orderMapper.appDetail(item.getId());
|
||||
List<OrderItemVO> orderItemList = orderAppRespVO.getOrderItemList();
|
||||
if (!orderItemList.isEmpty()) {
|
||||
if (Integer.valueOf(1).equals(orderItemList.get(0).getGoodsType())) {
|
||||
if (Integer.valueOf(1).equals(orderItemList.getFirst().getGoodsType())) {
|
||||
item.setGoodsName("录像集");
|
||||
item.setOrderType("录像集");
|
||||
} else if (Integer.valueOf(2).equals(orderItemList.get(0).getGoodsType())) {
|
||||
} else if (Integer.valueOf(2).equals(orderItemList.getFirst().getGoodsType())) {
|
||||
item.setGoodsName("照片集");
|
||||
item.setOrderType("照片集");
|
||||
} else if (Integer.valueOf(0).equals(orderItemList.get(0).getGoodsType())) {
|
||||
} else if (Integer.valueOf(0).equals(orderItemList.getFirst().getGoodsType())) {
|
||||
item.setOrderType("旅行Vlog");
|
||||
item.setGoodsName(orderItemList.get(0).getGoodsName());
|
||||
item.setGoodsName(orderItemList.getFirst().getGoodsName());
|
||||
} else {
|
||||
item.setGoodsName("未知商品");
|
||||
item.setOrderType("未知商品");
|
||||
@ -182,7 +182,7 @@ public class OrderServiceImpl implements OrderService {
|
||||
goods.setCreateTime(sourceEntity.getCreateTime());
|
||||
goodsList.add(goods);
|
||||
}
|
||||
item.setShootingTime(memberVideoEntityList.get(0).getCreateTime());
|
||||
item.setShootingTime(memberVideoEntityList.getFirst().getCreateTime());
|
||||
}
|
||||
}
|
||||
} else if (Integer.valueOf(2).equals(item.getGoodsType())) { // 照片 goodsId就是人脸ID
|
||||
@ -204,7 +204,7 @@ public class OrderServiceImpl implements OrderService {
|
||||
goods.setCreateTime(sourceEntity.getCreateTime());
|
||||
goodsList.add(goods);
|
||||
}
|
||||
item.setShootingTime(memberVideoEntityList.get(0).getCreateTime());
|
||||
item.setShootingTime(memberVideoEntityList.getFirst().getCreateTime());
|
||||
}
|
||||
}
|
||||
} else if (Integer.valueOf(3).equals(item.getGoodsType())) { // 打印照片 goodsId就是memberPrintId
|
||||
@ -275,7 +275,7 @@ public class OrderServiceImpl implements OrderService {
|
||||
if (orderItems.size() > 1) {
|
||||
goodsName = "多项景区Vlog商品";
|
||||
} else {
|
||||
int type = orderItems.get(0).getGoodsType();
|
||||
int type = orderItems.getFirst().getGoodsType();
|
||||
if (type == 0) {
|
||||
goodsName = "景区Vlog视频";
|
||||
} else if (type == 1) {
|
||||
@ -357,13 +357,13 @@ public class OrderServiceImpl implements OrderService {
|
||||
List<SourceEntity> memberVideoEntityList = sourceMapper.listVideoByFaceRelation(orderReqQuery.getMemberId(), item.getFaceId());
|
||||
item.setCoverList(memberVideoEntityList.stream().map(SourceEntity::getUrl).collect(Collectors.toList()));
|
||||
if (!memberVideoEntityList.isEmpty()) {
|
||||
item.setShootingTime(memberVideoEntityList.get(0).getCreateTime());
|
||||
item.setShootingTime(memberVideoEntityList.getFirst().getCreateTime());
|
||||
}
|
||||
} else if (Integer.valueOf(2).equals(item.getGoodsType())) {
|
||||
List<SourceEntity> memberVideoEntityList = sourceMapper.listImageByFaceRelation(orderReqQuery.getMemberId(), item.getFaceId());
|
||||
item.setCoverList(memberVideoEntityList.stream().map(SourceEntity::getUrl).collect(Collectors.toList()));
|
||||
if (!memberVideoEntityList.isEmpty()) {
|
||||
item.setShootingTime(memberVideoEntityList.get(0).getCreateTime());
|
||||
item.setShootingTime(memberVideoEntityList.getFirst().getCreateTime());
|
||||
}
|
||||
} else if (Integer.valueOf(0).equals(item.getGoodsType())) {
|
||||
item.setCoverList(Collections.singletonList(item.getCoverUrl()));
|
||||
@ -434,15 +434,15 @@ public class OrderServiceImpl implements OrderService {
|
||||
OrderAppRespVO orderAppRespVO = orderMapper.appDetail(item.getId());
|
||||
List<OrderItemVO> orderItemList = orderAppRespVO.getOrderItemList();
|
||||
if (!orderItemList.isEmpty()) {
|
||||
if (Integer.valueOf(1).equals(orderItemList.get(0).getGoodsType())) {
|
||||
if (Integer.valueOf(1).equals(orderItemList.getFirst().getGoodsType())) {
|
||||
item.setGoodsName("录像集");
|
||||
item.setOrderType("录像集");
|
||||
} else if (Integer.valueOf(2).equals(orderItemList.get(0).getGoodsType())) {
|
||||
} else if (Integer.valueOf(2).equals(orderItemList.getFirst().getGoodsType())) {
|
||||
item.setGoodsName("照片集");
|
||||
item.setOrderType("照片集");
|
||||
} else if (Integer.valueOf(0).equals(orderItemList.get(0).getGoodsType())) {
|
||||
} else if (Integer.valueOf(0).equals(orderItemList.getFirst().getGoodsType())) {
|
||||
item.setOrderType("旅行Vlog");
|
||||
item.setGoodsName(orderItemList.get(0).getGoodsName());
|
||||
item.setGoodsName(orderItemList.getFirst().getGoodsName());
|
||||
} else {
|
||||
item.setGoodsName("未知商品");
|
||||
item.setOrderType("未知商品");
|
||||
|
@ -61,7 +61,7 @@ public class RoleServiceImpl implements RoleService {
|
||||
String roleId = SnowFlakeUtil.getId();
|
||||
addOrUpdateRoleReqVO.setId(roleId);
|
||||
if(roleMapper.add(addOrUpdateRoleReqVO)>0){
|
||||
if(addOrUpdateRoleReqVO.getMenuIdList()!=null&addOrUpdateRoleReqVO.getMenuIdList().size()>0) {
|
||||
if (addOrUpdateRoleReqVO.getMenuIdList() != null && !addOrUpdateRoleReqVO.getMenuIdList().isEmpty()) {
|
||||
menuMapper.addRoleMenu(roleId, addOrUpdateRoleReqVO.getMenuIdList());
|
||||
}
|
||||
return ApiResponse.success(null);
|
||||
@ -69,8 +69,8 @@ public class RoleServiceImpl implements RoleService {
|
||||
}else {
|
||||
if(roleMapper.update(addOrUpdateRoleReqVO)>0){
|
||||
menuMapper.deleteRoleMenuByRoleId(addOrUpdateRoleReqVO.getId());
|
||||
if(addOrUpdateRoleReqVO.getMenuIdList()!=null&addOrUpdateRoleReqVO.getMenuIdList().size()>0){
|
||||
menuMapper.addRoleMenu(addOrUpdateRoleReqVO.getId(),addOrUpdateRoleReqVO.getMenuIdList());
|
||||
if (addOrUpdateRoleReqVO.getMenuIdList() != null && !addOrUpdateRoleReqVO.getMenuIdList().isEmpty()) {
|
||||
menuMapper.addRoleMenu(addOrUpdateRoleReqVO.getId(), addOrUpdateRoleReqVO.getMenuIdList());
|
||||
}
|
||||
return ApiResponse.success(null);
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ public class TemplateServiceImpl implements TemplateService {
|
||||
}
|
||||
Optional<TemplateRespVO> templateOptional = scenicTemplateList.stream().filter(item -> item.getId().equals(templateId)).findAny();
|
||||
Optional<TemplateRespVO> afterTemplateOptional = scenicTemplateList.stream().filter(item -> item.getId().equals(afterTemplateId)).findAny();
|
||||
if (!templateOptional.isPresent()) {
|
||||
if (templateOptional.isEmpty()) {
|
||||
return ApiResponse.fail("模版不存在");
|
||||
}
|
||||
if (afterTemplateOptional.isPresent()) {
|
||||
|
@ -235,7 +235,7 @@ public class PrinterServiceImpl implements PrinterService {
|
||||
if (printerList.size() != 1) {
|
||||
throw new BaseException("请选择打印机");
|
||||
} else {
|
||||
printerId = printerList.get(0).getId();
|
||||
printerId = printerList.getFirst().getId();
|
||||
}
|
||||
} else {
|
||||
PrinterEntity printer = printerMapper.getById(printerId);
|
||||
@ -293,7 +293,6 @@ public class PrinterServiceImpl implements PrinterService {
|
||||
if (order.getPayPrice().equals(BigDecimal.ZERO)) {
|
||||
orderBiz.paidOrder(order.getId());
|
||||
data.put("needPay", false);
|
||||
return data;
|
||||
} else {
|
||||
WXPayOrderReqVO wxPayOrderReqVO = new WXPayOrderReqVO();
|
||||
wxPayOrderReqVO.setOpenId(order.getOpenId())
|
||||
@ -308,8 +307,8 @@ public class PrinterServiceImpl implements PrinterService {
|
||||
throw new BaseException(e);
|
||||
}
|
||||
data.put("orderId", orderId);
|
||||
return data;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -41,9 +41,7 @@ import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.aliyuncs.IAcsClient;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@ -84,7 +82,7 @@ public class TaskFaceServiceImpl implements TaskFaceService {
|
||||
|
||||
private IAcsClient getClient() {
|
||||
AliFaceBodyAdapter use = (AliFaceBodyAdapter) FaceBodyFactory.use();
|
||||
return use.getClient().getClient();
|
||||
return use.getClient().client();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -222,7 +220,7 @@ public class TaskFaceServiceImpl implements TaskFaceService {
|
||||
if (StringUtils.isNumeric(dbName)) { // 景区
|
||||
allFaceSampleList = faceSampleMapper.listByIds(allFaceSampleIds);
|
||||
if (!acceptFaceSampleIds.isEmpty()) {
|
||||
Long firstFaceSampleId = acceptFaceSampleIds.get(0);
|
||||
Long firstFaceSampleId = acceptFaceSampleIds.getFirst();
|
||||
Optional<FaceSampleEntity> firstFaceSample = allFaceSampleList.stream().filter(faceSample -> faceSample.getId().equals(firstFaceSampleId)).findAny();
|
||||
if (firstFaceSample.isPresent()) {
|
||||
if (tourMinutes > 0) {
|
||||
|
@ -130,8 +130,7 @@ public class TaskTaskServiceImpl implements TaskService {
|
||||
if (accessKey == null) {
|
||||
return null;
|
||||
}
|
||||
RenderWorkerEntity worker = renderWorkerMapper.findByAccessKey(accessKey);
|
||||
return worker;
|
||||
return renderWorkerMapper.findByAccessKey(accessKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -209,9 +208,6 @@ public class TaskTaskServiceImpl implements TaskService {
|
||||
|
||||
@Override
|
||||
public TemplateRespVO workerGetTemplate(@NonNull Long templateId, @NonNull WorkerAuthReqVo req) {
|
||||
if (templateId == null) {
|
||||
return null;
|
||||
}
|
||||
RenderWorkerEntity worker = getWorker(req);
|
||||
if (worker == null) {
|
||||
return null;
|
||||
@ -274,7 +270,7 @@ public class TaskTaskServiceImpl implements TaskService {
|
||||
if (templatePlaceholder.stream().distinct().count() == templatePlaceholder.size()) {
|
||||
sourcesMap.forEach((key, value) -> {
|
||||
// 每个value只保留第一个
|
||||
value.removeIf(item -> !value.get(0).equals(item));
|
||||
value.removeIf(item -> !value.getFirst().equals(item));
|
||||
});
|
||||
} else {
|
||||
log.info("task callback: 模板占位符有重复,templateId: {}", templateId);
|
||||
@ -300,7 +296,7 @@ public class TaskTaskServiceImpl implements TaskService {
|
||||
taskReqQuery.setTemplateId(templateId);
|
||||
List<TaskEntity> templateTaskList = taskMapper.listEntity(taskReqQuery);
|
||||
if (!templateTaskList.isEmpty()) {
|
||||
taskEntity = templateTaskList.get(0);
|
||||
taskEntity = templateTaskList.getFirst();
|
||||
log.info("已有旧生成的视频:{}", taskEntity);
|
||||
MemberVideoEntity taskVideoRelation = videoMapper.queryRelationByMemberTask(face.getMemberId(), taskEntity.getId());
|
||||
if (taskVideoRelation != null) {
|
||||
@ -326,10 +322,10 @@ public class TaskTaskServiceImpl implements TaskService {
|
||||
memberVideoEntity.setTaskId(taskEntity.getId());
|
||||
} else {
|
||||
log.info("重复task! faceId:{},templateId:{},taskParams:{}", faceId, templateId, sourcesMap);
|
||||
memberVideoEntity.setTaskId(list.get(0).getId());
|
||||
VideoEntity video = videoMapper.findByTaskId(list.get(0).getId());
|
||||
memberVideoEntity.setTaskId(list.getFirst().getId());
|
||||
VideoEntity video = videoMapper.findByTaskId(list.getFirst().getId());
|
||||
if (video != null) {
|
||||
IsBuyRespVO isBuy = orderBiz.isBuy(face.getMemberId(), list.get(0).getScenicId(), 0, video.getId());
|
||||
IsBuyRespVO isBuy = orderBiz.isBuy(face.getMemberId(), list.getFirst().getScenicId(), 0, video.getId());
|
||||
if (isBuy.isBuy()) {
|
||||
memberVideoEntity.setIsBuy(1);
|
||||
memberVideoEntity.setOrderId(isBuy.getOrderId());
|
||||
@ -376,11 +372,9 @@ public class TaskTaskServiceImpl implements TaskService {
|
||||
}
|
||||
if (Integer.valueOf(3).equals(scenicConfig.getBookRoutine()) || Integer.valueOf(4).equals(scenicConfig.getBookRoutine())) {
|
||||
// 生成全部视频的逻辑
|
||||
templateList.forEach(template -> {
|
||||
createTaskByFaceIdAndTempalteId(faceId, template.getId(), 1);
|
||||
});
|
||||
templateList.forEach(template -> createTaskByFaceIdAndTempalteId(faceId, template.getId(), 1));
|
||||
} else {
|
||||
createTaskByFaceIdAndTempalteId(faceId, templateList.get(0).getId(), 1);
|
||||
createTaskByFaceIdAndTempalteId(faceId, templateList.getFirst().getId(), 1);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
@ -433,7 +427,7 @@ public class TaskTaskServiceImpl implements TaskService {
|
||||
// }
|
||||
// videoMapper.addRelation(memberVideo);
|
||||
// new Thread(() -> {
|
||||
// sendVideoGeneratedServiceNotification(list.get(0).getId(), faceRespVO.getMemberId());
|
||||
// sendVideoGeneratedServiceNotification(list.getFirst().getId(), faceRespVO.getMemberId());
|
||||
// }).start();
|
||||
// }
|
||||
// });
|
||||
@ -474,7 +468,7 @@ public class TaskTaskServiceImpl implements TaskService {
|
||||
if (templatePlaceholder.stream().distinct().count() == templatePlaceholder.size()) {
|
||||
sourcesMap.forEach((key, value) -> {
|
||||
// 每个value只保留第一个
|
||||
value.removeIf(item -> !value.get(0).equals(item));
|
||||
value.removeIf(item -> !value.getFirst().equals(item));
|
||||
});
|
||||
} else {
|
||||
log.info("task callback: 模板占位符有重复,templateId: {}", templateId);
|
||||
@ -500,7 +494,7 @@ public class TaskTaskServiceImpl implements TaskService {
|
||||
taskReqQuery.setTemplateId(templateId);
|
||||
List<TaskEntity> templateTaskList = taskMapper.listEntity(taskReqQuery);
|
||||
if (!templateTaskList.isEmpty()) {
|
||||
taskEntity = templateTaskList.get(0);
|
||||
taskEntity = templateTaskList.getFirst();
|
||||
log.info("已有旧生成的视频:{}", taskEntity);
|
||||
MemberVideoEntity taskVideoRelation = videoMapper.queryRelationByMemberTask(face.getMemberId(), taskEntity.getId());
|
||||
if (taskVideoRelation != null) {
|
||||
@ -526,10 +520,10 @@ public class TaskTaskServiceImpl implements TaskService {
|
||||
memberVideoEntity.setTaskId(taskEntity.getId());
|
||||
} else {
|
||||
log.info("重复task! faceId:{},templateId:{},taskParams:{}", faceId, templateId, sourcesMap);
|
||||
memberVideoEntity.setTaskId(list.get(0).getId());
|
||||
VideoEntity video = videoMapper.findByTaskId(list.get(0).getId());
|
||||
memberVideoEntity.setTaskId(list.getFirst().getId());
|
||||
VideoEntity video = videoMapper.findByTaskId(list.getFirst().getId());
|
||||
if (video != null) {
|
||||
IsBuyRespVO isBuy = orderBiz.isBuy(face.getMemberId(), list.get(0).getScenicId(), 0, video.getId());
|
||||
IsBuyRespVO isBuy = orderBiz.isBuy(face.getMemberId(), list.getFirst().getScenicId(), 0, video.getId());
|
||||
if (isBuy.isBuy()) {
|
||||
memberVideoEntity.setIsBuy(1);
|
||||
memberVideoEntity.setOrderId(isBuy.getOrderId());
|
||||
@ -626,9 +620,7 @@ public class TaskTaskServiceImpl implements TaskService {
|
||||
}
|
||||
}
|
||||
videoMapper.updateRelationWhenTaskSuccess(taskId, video.getId(), isBuy);
|
||||
new Thread(() -> {
|
||||
sendVideoGeneratedServiceNotification(taskId);
|
||||
}).start();
|
||||
new Thread(() -> sendVideoGeneratedServiceNotification(taskId)).start();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -657,6 +649,9 @@ public class TaskTaskServiceImpl implements TaskService {
|
||||
return null;
|
||||
}
|
||||
RenderWorkerEntity worker = getWorker(req);
|
||||
if (worker == null) {
|
||||
return null;
|
||||
}
|
||||
IStorageAdapter adapter;
|
||||
try {
|
||||
adapter = StorageFactory.get(worker.getStoreType());
|
||||
@ -677,9 +672,7 @@ public class TaskTaskServiceImpl implements TaskService {
|
||||
|
||||
public void sendVideoGeneratedServiceNotification(Long taskId) {
|
||||
List<MemberVideoEntity> memberVideo = videoMapper.listRelationByTask(taskId);
|
||||
memberVideo.forEach(item -> {
|
||||
sendVideoGeneratedServiceNotification(taskId, item.getMemberId());
|
||||
});
|
||||
memberVideo.forEach(item -> sendVideoGeneratedServiceNotification(taskId, item.getMemberId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -21,16 +21,12 @@ public class StorageFactory {
|
||||
}
|
||||
|
||||
public static IStorageAdapter get(StorageType storageType) {
|
||||
switch (storageType) {
|
||||
case LOCAL:
|
||||
return new LocalStorageAdapter();
|
||||
case AWS_OSS:
|
||||
return new AwsOssAdapter();
|
||||
case ALI_OSS:
|
||||
return new AliOssAdapter();
|
||||
default:
|
||||
throw new StorageUnsupportedException(storageType.getType());
|
||||
}
|
||||
return switch (storageType) {
|
||||
case LOCAL -> new LocalStorageAdapter();
|
||||
case AWS_OSS -> new AwsOssAdapter();
|
||||
case ALI_OSS -> new AliOssAdapter();
|
||||
default -> throw new StorageUnsupportedException(storageType.getType());
|
||||
};
|
||||
}
|
||||
|
||||
public static IStorageAdapter get(String type) {
|
||||
|
@ -190,18 +190,13 @@ final public class AliOssAdapter extends AStorageAdapter {
|
||||
}
|
||||
|
||||
private CannedAccessControlList convertAcl(StorageAcl acl) {
|
||||
switch (acl) {
|
||||
case PUBLIC_READ:
|
||||
return CannedAccessControlList.PublicRead;
|
||||
case PUBLIC_READ_WRITE:
|
||||
return CannedAccessControlList.PublicReadWrite;
|
||||
case PRIVATE:
|
||||
return CannedAccessControlList.Private;
|
||||
case AUTHENTICATED_READ:
|
||||
return CannedAccessControlList.AuthenticatedRead;
|
||||
default:
|
||||
return CannedAccessControlList.Default;
|
||||
}
|
||||
return switch (acl) {
|
||||
case PUBLIC_READ -> CannedAccessControlList.PublicRead;
|
||||
case PUBLIC_READ_WRITE -> CannedAccessControlList.PublicReadWrite;
|
||||
case PRIVATE -> CannedAccessControlList.Private;
|
||||
case AUTHENTICATED_READ -> CannedAccessControlList.AuthenticatedRead;
|
||||
default -> CannedAccessControlList.Default;
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -61,7 +61,7 @@ public class AwsOssAdapter extends AStorageAdapter {
|
||||
}
|
||||
String fullPath = buildPath(path);
|
||||
try (S3Wrapper wrapper = getS3Client()) {
|
||||
AmazonS3Client s3Client = wrapper.getS3Client();
|
||||
AmazonS3Client s3Client = wrapper.s3Client();
|
||||
ObjectMetadata metadata = new ObjectMetadata();
|
||||
metadata.setContentLength(inputStream.available());
|
||||
if (StringUtils.isNotBlank(contentType)) {
|
||||
@ -79,7 +79,7 @@ public class AwsOssAdapter extends AStorageAdapter {
|
||||
@Override
|
||||
public boolean deleteFile(String... path) {
|
||||
try (S3Wrapper wrapper = getS3Client()) {
|
||||
AmazonS3Client s3Client = wrapper.getS3Client();
|
||||
AmazonS3Client s3Client = wrapper.s3Client();
|
||||
s3Client.deleteObject(config.getBucketName(), buildPath(path));
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
@ -95,7 +95,7 @@ public class AwsOssAdapter extends AStorageAdapter {
|
||||
@Override
|
||||
public String getUrlForDownload(Date expireDate, String... path) {
|
||||
try (S3Wrapper wrapper = getS3Client()) {
|
||||
AmazonS3Client s3Client = wrapper.getS3Client();
|
||||
AmazonS3Client s3Client = wrapper.s3Client();
|
||||
URL url = s3Client.generatePresignedUrl(config.getBucketName(), buildPath(path), expireDate);
|
||||
return url.toString();
|
||||
}
|
||||
@ -104,7 +104,7 @@ public class AwsOssAdapter extends AStorageAdapter {
|
||||
@Override
|
||||
public String getUrlForUpload(Date expireDate, String contentType, String... path) {
|
||||
try (S3Wrapper wrapper = getS3Client()) {
|
||||
AmazonS3Client s3Client = wrapper.getS3Client();
|
||||
AmazonS3Client s3Client = wrapper.s3Client();
|
||||
GeneratePresignedUrlRequest request = new GeneratePresignedUrlRequest(config.getBucketName(), buildPath(path));
|
||||
request.setMethod(HttpMethod.PUT);
|
||||
if (StringUtils.isNotBlank(contentType)) {
|
||||
@ -126,7 +126,7 @@ public class AwsOssAdapter extends AStorageAdapter {
|
||||
String continuationToken = null;
|
||||
List<S3ObjectSummary> objectList = new ArrayList<>();
|
||||
try (S3Wrapper wrapper = getS3Client()) {
|
||||
AmazonS3Client s3Client = wrapper.getS3Client();
|
||||
AmazonS3Client s3Client = wrapper.s3Client();
|
||||
while (isTruncated) {
|
||||
if (continuationToken != null) {
|
||||
listObjectsV2Request.setContinuationToken(continuationToken);
|
||||
@ -160,7 +160,7 @@ public class AwsOssAdapter extends AStorageAdapter {
|
||||
return true;
|
||||
}
|
||||
try (S3Wrapper wrapper = getS3Client()) {
|
||||
AmazonS3Client s3Client = wrapper.getS3Client();
|
||||
AmazonS3Client s3Client = wrapper.s3Client();
|
||||
int idx = 0;
|
||||
int batchSize = 999;
|
||||
while (objectList.size() > idx) {
|
||||
@ -184,24 +184,19 @@ public class AwsOssAdapter extends AStorageAdapter {
|
||||
}
|
||||
|
||||
private CannedAccessControlList convertAcl(StorageAcl acl) {
|
||||
switch (acl) {
|
||||
case PUBLIC_READ:
|
||||
return CannedAccessControlList.PublicRead;
|
||||
case PUBLIC_READ_WRITE:
|
||||
return CannedAccessControlList.PublicReadWrite;
|
||||
case PRIVATE:
|
||||
return CannedAccessControlList.Private;
|
||||
case AUTHENTICATED_READ:
|
||||
return CannedAccessControlList.AuthenticatedRead;
|
||||
default:
|
||||
return CannedAccessControlList.PublicRead;
|
||||
}
|
||||
return switch (acl) {
|
||||
case PUBLIC_READ -> CannedAccessControlList.PublicRead;
|
||||
case PUBLIC_READ_WRITE -> CannedAccessControlList.PublicReadWrite;
|
||||
case PRIVATE -> CannedAccessControlList.Private;
|
||||
case AUTHENTICATED_READ -> CannedAccessControlList.AuthenticatedRead;
|
||||
default -> CannedAccessControlList.PublicRead;
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setAcl(StorageAcl acl, String... path) {
|
||||
try (S3Wrapper wrapper = getS3Client()) {
|
||||
AmazonS3Client s3Client = wrapper.getS3Client();
|
||||
AmazonS3Client s3Client = wrapper.s3Client();
|
||||
s3Client.setObjectAcl(config.getBucketName(), buildPath(path), convertAcl(acl));
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
@ -212,7 +207,7 @@ public class AwsOssAdapter extends AStorageAdapter {
|
||||
@Override
|
||||
public boolean isExists(String... path) {
|
||||
try (S3Wrapper wrapper = getS3Client()) {
|
||||
AmazonS3Client s3Client = wrapper.getS3Client();
|
||||
AmazonS3Client s3Client = wrapper.s3Client();
|
||||
return s3Client.doesObjectExist(config.getBucketName(), buildPath(path));
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
@ -242,18 +237,7 @@ public class AwsOssAdapter extends AStorageAdapter {
|
||||
return StorageUtil.getRelativePath(path, config.getPrefix());
|
||||
}
|
||||
|
||||
public static class S3Wrapper implements AutoCloseable {
|
||||
private final AmazonS3Client s3Client;
|
||||
|
||||
public S3Wrapper(AmazonS3Client s3Client) {
|
||||
this.s3Client = s3Client;
|
||||
}
|
||||
|
||||
// 提供对原始对象的方法访问
|
||||
public AmazonS3Client getS3Client() {
|
||||
return s3Client;
|
||||
}
|
||||
|
||||
public record S3Wrapper(AmazonS3Client s3Client) implements AutoCloseable {
|
||||
@Override
|
||||
public void close() {
|
||||
s3Client.shutdown();
|
||||
|
@ -1,5 +1,8 @@
|
||||
package com.ycwl.basic.storage.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public enum StorageAcl {
|
||||
PUBLIC_READ("public-read"),
|
||||
PRIVATE("private"),
|
||||
@ -12,7 +15,4 @@ public enum StorageAcl {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ public class DynamicTaskGenerator {
|
||||
}
|
||||
log.info("开始执行任务:{}", task);
|
||||
IFaceBodyAdapter faceBodyAdapter;
|
||||
if (scenicConfig != null && scenicConfig.getFaceType() != null) {
|
||||
if (scenicConfig.getFaceType() != null) {
|
||||
faceBodyAdapter = FaceBodyFactory.getAdapter(scenicConfig.getFaceType());
|
||||
faceBodyAdapter.loadConfig(JSONObject.parseObject(scenicConfig.getFaceConfigJson(), Map.class));
|
||||
} else {
|
||||
|
@ -77,7 +77,7 @@ public class VideoPieceGetter {
|
||||
public Long templateId;
|
||||
public boolean force;
|
||||
|
||||
public static interface Callback {
|
||||
public interface Callback {
|
||||
void onInvoke();
|
||||
}
|
||||
}
|
||||
@ -134,7 +134,7 @@ public class VideoPieceGetter {
|
||||
List<FaceSampleEntity> list = faceSampleMapper.listByIds(task.getFaceSampleIds());
|
||||
Map<Long, Long> pairDeviceMap = new ConcurrentHashMap<>();
|
||||
if (!list.isEmpty()) {
|
||||
Long scenicId = list.get(0).getScenicId();
|
||||
Long scenicId = list.getFirst().getScenicId();
|
||||
List<DeviceEntity> allDeviceByScenicId = deviceRepository.getAllDeviceByScenicId(scenicId);
|
||||
allDeviceByScenicId.forEach(device -> {
|
||||
Long deviceId = device.getId();
|
||||
@ -258,10 +258,10 @@ public class VideoPieceGetter {
|
||||
log.info("查询到可用的文件: {}", listByDtRange);
|
||||
// 如果完全一致,就不需要裁切
|
||||
String url;
|
||||
if (listByDtRange.size() == 1 && listByDtRange.get(0).isExact()) {
|
||||
url = listByDtRange.get(0).getUrl();
|
||||
if (listByDtRange.size() == 1 && listByDtRange.getFirst().isExact()) {
|
||||
url = listByDtRange.getFirst().getUrl();
|
||||
} else {
|
||||
long offset = baseTime.getTime() - cutPre.multiply(BigDecimal.valueOf(1000)).longValue() - listByDtRange.get(0).getCreateTime().getTime();
|
||||
long offset = baseTime.getTime() - cutPre.multiply(BigDecimal.valueOf(1000)).longValue() - listByDtRange.getFirst().getCreateTime().getTime();
|
||||
FfmpegTask ffmpegTask = new FfmpegTask();
|
||||
ffmpegTask.setFileList(listByDtRange);
|
||||
ffmpegTask.setDuration(duration);
|
||||
@ -422,7 +422,7 @@ public class VideoPieceGetter {
|
||||
|
||||
private boolean runFfmpegForSingleFile(FfmpegTask task) {
|
||||
try {
|
||||
return quickVideoCut(task.getFileList().get(0).getUrl(), task.getOffsetStart(), task.getDuration(), task.getOutputFile());
|
||||
return quickVideoCut(task.getFileList().getFirst().getUrl(), task.getOffsetStart(), task.getDuration(), task.getOutputFile());
|
||||
} catch (IOException e) {
|
||||
return false;
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ public class VideoTaskGenerator {
|
||||
}
|
||||
});
|
||||
} else {
|
||||
Long templateId = contentList.get(0).getTemplateId();
|
||||
Long templateId = contentList.getFirst().getTemplateId();
|
||||
boolean canAutoGenerate = templateBiz.determineTemplateCanAutoGenerate(templateId, face.getId(), false);
|
||||
if (canAutoGenerate) {
|
||||
log.info("task callback: 自动生成");
|
||||
|
@ -12,7 +12,7 @@ public class ApiConst {
|
||||
*
|
||||
* @version 1.0.0
|
||||
*/
|
||||
public static enum Code {
|
||||
public enum Code {
|
||||
|
||||
/**
|
||||
* 成功返回码
|
||||
@ -94,11 +94,11 @@ public class ApiConst {
|
||||
*/
|
||||
CODE_MISS_TOKEN_ERROR(5006);
|
||||
|
||||
private Code(int intCode) {
|
||||
Code(int intCode) {
|
||||
this.intCode = intCode;
|
||||
}
|
||||
|
||||
private int intCode;
|
||||
private final int intCode;
|
||||
|
||||
public int code() {
|
||||
return intCode;
|
||||
|
@ -6,6 +6,7 @@ import com.ycwl.basic.enums.BizCodeEnum;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
@ -17,6 +18,7 @@ import java.io.Serializable;
|
||||
@ApiModel(value = "通用返回数据对象")
|
||||
public class ApiResponse<T> implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
@ -48,7 +50,7 @@ public class ApiResponse<T> implements Serializable {
|
||||
* @return
|
||||
*/
|
||||
public static <T> ApiResponse<T> success(T data) {
|
||||
ApiResponse<T> response = new ApiResponse<T>();
|
||||
ApiResponse<T> response = new ApiResponse<>();
|
||||
response.setCode(ApiConst.Code.CODE_SUCCESS.code());
|
||||
response.setData(data);
|
||||
return response;
|
||||
@ -60,7 +62,7 @@ public class ApiResponse<T> implements Serializable {
|
||||
* @return
|
||||
*/
|
||||
public static <T> ApiResponse<T> buildEmptyResponse() {
|
||||
ApiResponse<T> response = new ApiResponse<T>();
|
||||
ApiResponse<T> response = new ApiResponse<>();
|
||||
response.setCode(ApiConst.Code.CODE_CONTENT_EMPTY.code());
|
||||
return response;
|
||||
}
|
||||
@ -84,7 +86,7 @@ public class ApiResponse<T> implements Serializable {
|
||||
* @return
|
||||
*/
|
||||
public static <T> ApiResponse<T> buildResponse(int code, T data, String msg) {
|
||||
ApiResponse<T> response = new ApiResponse<T>();
|
||||
ApiResponse<T> response = new ApiResponse<>();
|
||||
response.setCode(code);
|
||||
response.setData(data);
|
||||
response.setMsg(msg);
|
||||
@ -99,7 +101,7 @@ public class ApiResponse<T> implements Serializable {
|
||||
* @return
|
||||
*/
|
||||
public static <T> ApiResponse<T> buildFlagResponse(boolean flag, T data) {
|
||||
ApiResponse<T> response = new ApiResponse<T>();
|
||||
ApiResponse<T> response = new ApiResponse<>();
|
||||
if (flag) {
|
||||
response.setCode(ApiConst.Code.CODE_SUCCESS.code());
|
||||
response.setData(data);
|
||||
@ -120,7 +122,7 @@ public class ApiResponse<T> implements Serializable {
|
||||
* @return
|
||||
*/
|
||||
public static <T> ApiResponse<T> buildResponse(ApiConst.Code code, String msg) {
|
||||
ApiResponse<T> response = new ApiResponse<T>();
|
||||
ApiResponse<T> response = new ApiResponse<>();
|
||||
response.setCode(code.code());
|
||||
response.setMsg(msg);
|
||||
return response;
|
||||
@ -134,7 +136,7 @@ public class ApiResponse<T> implements Serializable {
|
||||
* @return
|
||||
*/
|
||||
public static <T> ApiResponse<T> buildResponse(int code, String msg) {
|
||||
ApiResponse<T> response = new ApiResponse<T>();
|
||||
ApiResponse<T> response = new ApiResponse<>();
|
||||
response.setCode(code);
|
||||
response.setMsg(msg);
|
||||
return response;
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.ycwl.basic.utils;
|
||||
|
||||
import cn.hutool.core.codec.Base64;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
@ -7,16 +8,15 @@ import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Base64;
|
||||
|
||||
public class ImageUtils {
|
||||
public static MultipartFile base64ToMultipartFile(String base64) {
|
||||
String[] baseStrs = base64.split(",");
|
||||
byte[] b;
|
||||
b = Base64.getDecoder().decode(baseStrs[0]);
|
||||
b = Base64.decode(baseStrs[0]);
|
||||
for (int i = 0; i < b.length; ++i) {
|
||||
if (b[i] < 0) {
|
||||
b[i] += 256;
|
||||
b[i] += (byte) 256;
|
||||
}
|
||||
}
|
||||
return new Base64DecodedMultipartFile(b, baseStrs[0]);
|
||||
@ -33,14 +33,12 @@ public class ImageUtils {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
// TODO - implementation depends on your requirements
|
||||
return System.currentTimeMillis() + Math.random() + "." + header.split("/")[1];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOriginalFilename() {
|
||||
// TODO - implementation depends on your requirements
|
||||
return System.currentTimeMillis() + (int) Math.random() * 10000 + "." + header.split("/")[1];
|
||||
return System.currentTimeMillis() + "." + header.split("/")[1];
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -3,8 +3,6 @@ package com.ycwl.basic.utils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
/**
|
||||
* 获取IP方法
|
||||
@ -43,106 +41,6 @@ public class IpUtils {
|
||||
return "0:0:0:0:0:0:0:1".equals(ip) ? "127.0.0.1" : getMultistageReverseProxyIp(ip);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将IPv4地址转换成字节
|
||||
*
|
||||
* @param text IPv4地址
|
||||
* @return byte 字节
|
||||
*/
|
||||
public static byte[] textToNumericFormatV4(String text) {
|
||||
if (text.length() == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
byte[] bytes = new byte[4];
|
||||
String[] elements = text.split("\\." , -1);
|
||||
try {
|
||||
long l;
|
||||
int i;
|
||||
switch (elements.length) {
|
||||
case 1:
|
||||
l = Long.parseLong(elements[0]);
|
||||
if ((l < 0L) || (l > 4294967295L)) {
|
||||
return null;
|
||||
}
|
||||
bytes[0] = (byte) (int) (l >> 24 & 0xFF);
|
||||
bytes[1] = (byte) (int) ((l & 0xFFFFFF) >> 16 & 0xFF);
|
||||
bytes[2] = (byte) (int) ((l & 0xFFFF) >> 8 & 0xFF);
|
||||
bytes[3] = (byte) (int) (l & 0xFF);
|
||||
break;
|
||||
case 2:
|
||||
l = Integer.parseInt(elements[0]);
|
||||
if ((l < 0L) || (l > 255L)) {
|
||||
return null;
|
||||
}
|
||||
bytes[0] = (byte) (int) (l & 0xFF);
|
||||
l = Integer.parseInt(elements[1]);
|
||||
if ((l < 0L) || (l > 16777215L)) {
|
||||
return null;
|
||||
}
|
||||
bytes[1] = (byte) (int) (l >> 16 & 0xFF);
|
||||
bytes[2] = (byte) (int) ((l & 0xFFFF) >> 8 & 0xFF);
|
||||
bytes[3] = (byte) (int) (l & 0xFF);
|
||||
break;
|
||||
case 3:
|
||||
for (i = 0; i < 2; ++i) {
|
||||
l = Integer.parseInt(elements[i]);
|
||||
if ((l < 0L) || (l > 255L)) {
|
||||
return null;
|
||||
}
|
||||
bytes[i] = (byte) (int) (l & 0xFF);
|
||||
}
|
||||
l = Integer.parseInt(elements[2]);
|
||||
if ((l < 0L) || (l > 65535L)) {
|
||||
return null;
|
||||
}
|
||||
bytes[2] = (byte) (int) (l >> 8 & 0xFF);
|
||||
bytes[3] = (byte) (int) (l & 0xFF);
|
||||
break;
|
||||
case 4:
|
||||
for (i = 0; i < 4; ++i) {
|
||||
l = Integer.parseInt(elements[i]);
|
||||
if ((l < 0L) || (l > 255L)) {
|
||||
return null;
|
||||
}
|
||||
bytes[i] = (byte) (int) (l & 0xFF);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
return null;
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取IP地址
|
||||
*
|
||||
* @return 本地IP地址
|
||||
*/
|
||||
public static String getHostIp() {
|
||||
try {
|
||||
return InetAddress.getLocalHost().getHostAddress();
|
||||
} catch (UnknownHostException e) {
|
||||
}
|
||||
return "127.0.0.1";
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取主机名
|
||||
*
|
||||
* @return 本地主机名
|
||||
*/
|
||||
public static String getHostName() {
|
||||
try {
|
||||
return InetAddress.getLocalHost().getHostName();
|
||||
} catch (UnknownHostException e) {
|
||||
}
|
||||
return "未知";
|
||||
}
|
||||
|
||||
/**
|
||||
* 从多级反向代理中获得第一个非unknown IP地址
|
||||
*
|
||||
@ -154,7 +52,7 @@ public class IpUtils {
|
||||
if (ip != null && ip.indexOf(",") > 0) {
|
||||
final String[] ips = ip.trim().split(",");
|
||||
for (String subIp : ips) {
|
||||
if (false == isUnknown(subIp)) {
|
||||
if (!isUnknown(subIp)) {
|
||||
ip = subIp;
|
||||
break;
|
||||
}
|
||||
|
@ -10,7 +10,6 @@ import io.jsonwebtoken.SignatureAlgorithm;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@ -48,9 +47,8 @@ public class JwtAnalysisUtil {
|
||||
*/
|
||||
public static JwtInfo getInfoFromToken(String token, byte[] pubKey) throws Exception {
|
||||
Claims body = (Claims) RsaKeyUtil.parserToken(token, pubKey).getBody();
|
||||
Iterator var3 = body.entrySet().iterator();
|
||||
while (var3.hasNext()) {
|
||||
Map.Entry entry = (Map.Entry) var3.next();
|
||||
for (Map.Entry<String, Object> stringObjectEntry : body.entrySet()) {
|
||||
Map.Entry<String, Object> entry = stringObjectEntry;
|
||||
if (!"sub".equals(entry.getKey())
|
||||
&& !"userId".equals(entry.getKey())
|
||||
&& !"phone".equals(entry.getKey())
|
||||
@ -59,7 +57,7 @@ public class JwtAnalysisUtil {
|
||||
&& !"name".equals(entry.getKey())
|
||||
&& !"roleName".equals(entry.getKey())
|
||||
&& !"scenicId".equals(entry.getKey())
|
||||
&& !"expire".equals(entry.getKey()));
|
||||
&& !"expire".equals(entry.getKey())) ;
|
||||
}
|
||||
|
||||
// convert
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.ycwl.basic.utils;
|
||||
|
||||
import cn.hutool.core.codec.Base64;
|
||||
import io.jsonwebtoken.Claims;
|
||||
import io.jsonwebtoken.Jws;
|
||||
import io.jsonwebtoken.Jwts;
|
||||
@ -8,14 +9,13 @@ import java.io.IOException;
|
||||
import java.security.*;
|
||||
import java.security.spec.PKCS8EncodedKeySpec;
|
||||
import java.security.spec.X509EncodedKeySpec;
|
||||
import java.util.Base64;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author yangchen
|
||||
*/
|
||||
@SuppressWarnings("ALL")
|
||||
public class RsaKeyUtil {
|
||||
|
||||
public RsaKeyUtil() {
|
||||
@ -38,18 +38,18 @@ public class RsaKeyUtil {
|
||||
KeyPair keyPair;
|
||||
byte[] publicKeyBytes = (keyPair = keyPairGenerator.genKeyPair()).getPublic().getEncoded();
|
||||
byte[] privateKeyBytes = keyPair.getPrivate().getEncoded();
|
||||
HashMap map;
|
||||
(map = new HashMap()).put("pub", publicKeyBytes);
|
||||
HashMap<String, byte[]> map = new HashMap<>();
|
||||
map.put("pub", publicKeyBytes);
|
||||
map.put("pri", privateKeyBytes);
|
||||
return map;
|
||||
}
|
||||
|
||||
public static String toHexString(byte[] b) {
|
||||
return Base64.getEncoder().encodeToString(b);
|
||||
return Base64.encode(b);
|
||||
}
|
||||
|
||||
public static final byte[] toBytes(String s) throws IOException {
|
||||
return Base64.getDecoder().decode(s);
|
||||
public static byte[] toBytes(String s) throws IOException {
|
||||
return Base64.decode(s);
|
||||
}
|
||||
|
||||
public static Jws<Claims> parserToken(String token, byte[] pubKey) throws Exception {
|
||||
@ -67,7 +67,7 @@ public class RsaKeyUtil {
|
||||
SecureRandom secureRandom = new SecureRandom("123".getBytes());
|
||||
keyPairGenerator.initialize(1024, secureRandom);
|
||||
KeyPair keyPair = keyPairGenerator.genKeyPair();
|
||||
System.out.println(keyPair.getPublic().getEncoded());
|
||||
System.out.println(Arrays.toString(keyPair.getPublic().getEncoded()));
|
||||
|
||||
System.out.println("====");
|
||||
|
||||
|
@ -99,7 +99,6 @@ public class SnowFlakeUtil {
|
||||
public static long convert(UniqueId uniqueId) {
|
||||
long result = 0;
|
||||
try {
|
||||
result = 0L;
|
||||
|
||||
result |= uniqueId.getSequence();
|
||||
|
||||
|
Reference in New Issue
Block a user