礼物区域追加
This commit is contained in:
parent
8e4e8f5db2
commit
82e8dc0bfe
@ -38,14 +38,20 @@
|
||||
<artifactId>spring-boot-starter-jdbc</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>${mysql-connector-java.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.yaml</groupId>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>${mysql-connector-java.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>p6spy</groupId>
|
||||
<artifactId>p6spy</artifactId>
|
||||
<version>${p6spy.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.yaml</groupId>
|
||||
<artifactId>snakeyaml</artifactId>
|
||||
<version>${snakeyaml.version}</version>
|
||||
</dependency>
|
||||
@ -113,10 +119,11 @@
|
||||
|
||||
<properties>
|
||||
<maven.deploy.skip>true</maven.deploy.skip>
|
||||
<elasticjob.version>3.0.4</elasticjob.version>
|
||||
<snakeyaml.version>2.2</snakeyaml.version>
|
||||
<mysql-connector-java.version>8.0.33</mysql-connector-java.version>
|
||||
</properties>
|
||||
<elasticjob.version>3.0.4</elasticjob.version>
|
||||
<snakeyaml.version>2.2</snakeyaml.version>
|
||||
<mysql-connector-java.version>8.0.33</mysql-connector-java.version>
|
||||
<p6spy.version>3.8.5</p6spy.version>
|
||||
</properties>
|
||||
|
||||
<parent>
|
||||
<artifactId>rc-dependencies</artifactId>
|
||||
|
||||
@ -23,5 +23,5 @@ feign:
|
||||
|
||||
elasticjob:
|
||||
reg-center:
|
||||
server-lists: 127.0.0.1:2181
|
||||
server-lists: zookeeper:2181
|
||||
namespace: rc-scheduling-local
|
||||
|
||||
@ -27,6 +27,10 @@ spring:
|
||||
config:
|
||||
import:
|
||||
- optional:nacos:application.@register.file-extension@
|
||||
- optional:nacos:rds-config.@register.file-extension@?group=@config.group.common@
|
||||
- optional:nacos:redis-config.@register.file-extension@?group=@config.group.common@
|
||||
- optional:nacos:external.@register.file-extension@?refresh=true&group=@config.group.common@
|
||||
- optional:nacos:rocketmq.@register.file-extension@?group=@config.group.common@
|
||||
- optional:nacos:framework-config.@register.file-extension@?refresh=true&group=@config.group.common@
|
||||
|
||||
logging:
|
||||
|
||||
@ -25,12 +25,14 @@ spring:
|
||||
cache:
|
||||
ttl: 5s
|
||||
|
||||
config:
|
||||
import:
|
||||
- optional:nacos:application.@register.file-extension@?refresh=true&group=@artifactId@
|
||||
- optional:nacos:application-${spring-profile.active}.@register.file-extension@?refresh=true&group=@artifactId@
|
||||
- optional:nacos:${spring.application.name}-${spring-profile.active}.@register.file-extension@?refresh=true&group=@artifactId@
|
||||
- optional:nacos:rocketmq.@register.file-extension@?group=@config.group.common@
|
||||
config:
|
||||
import:
|
||||
- optional:nacos:application.@register.file-extension@?refresh=true&group=@artifactId@
|
||||
- optional:nacos:application-${spring-profile.active}.@register.file-extension@?refresh=true&group=@artifactId@
|
||||
- optional:nacos:${spring.application.name}-${spring-profile.active}.@register.file-extension@?refresh=true&group=@artifactId@
|
||||
- optional:nacos:rds-config.@register.file-extension@?group=@config.group.common@
|
||||
- optional:nacos:redis-config.@register.file-extension@?group=@config.group.common@
|
||||
- optional:nacos:rocketmq.@register.file-extension@?group=@config.group.common@
|
||||
# - optional:nacos:external.@register.file-extension@?refresh=true&group=@config.group.common@
|
||||
- optional:nacos:framework-config.@register.file-extension@?refresh=true&group=@config.group.common@
|
||||
|
||||
|
||||
@ -89,16 +89,23 @@ public interface GiftConfigClientApi {
|
||||
@PostMapping("/saveGift")
|
||||
ResultResponse<Boolean> saveGift(@RequestBody GiftConfigDTO giftConfig);
|
||||
|
||||
/**
|
||||
* 上下架礼物.
|
||||
*/
|
||||
@GetMapping("/switchDelStatus")
|
||||
ResultResponse<Boolean> switchDelStatus(@RequestParam("id") Long id,
|
||||
@RequestParam("status") Boolean status);
|
||||
|
||||
/**
|
||||
* 礼物列表.
|
||||
*/
|
||||
/**
|
||||
* 上下架礼物.
|
||||
*/
|
||||
@GetMapping("/switchDelStatus")
|
||||
ResultResponse<Boolean> switchDelStatus(@RequestParam("id") Long id,
|
||||
@RequestParam("status") Boolean status);
|
||||
|
||||
/**
|
||||
* 批量追加当前平台所有礼物区域.
|
||||
*/
|
||||
@PostMapping("/addAllGiftRegion")
|
||||
ResultResponse<Boolean> addAllGiftRegion(@RequestParam("sysOrigin") String sysOrigin,
|
||||
@RequestParam("regionId") String regionId);
|
||||
|
||||
/**
|
||||
* 礼物列表.
|
||||
*/
|
||||
@GetMapping("/listByTab")
|
||||
ResultResponse<List<GiftConfigDTO>> listByTab(@RequestParam("sysOrigin") String sysOrigin,
|
||||
@RequestParam("giftTab") String giftTab);
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
package com.red.circle.console.adapter.app.sys;
|
||||
|
||||
|
||||
import com.red.circle.console.app.dto.clienobject.sys.SysGiftConfigCO;
|
||||
import com.red.circle.console.app.dto.cmd.app.sys.GiftConsoleQryCmd;
|
||||
import com.red.circle.console.app.dto.clienobject.sys.SysGiftConfigCO;
|
||||
import com.red.circle.console.app.dto.cmd.app.sys.GiftConsoleQryCmd;
|
||||
import com.red.circle.console.app.dto.cmd.app.sys.GiftRegionAddCmd;
|
||||
import com.red.circle.console.app.service.app.sys.SysGiftConfigService;
|
||||
import com.red.circle.console.infra.annotations.OpsOperationReqLog;
|
||||
import com.red.circle.framework.dto.PageResult;
|
||||
@ -57,17 +58,35 @@ public class SysGiftConfigRestController extends BaseController {
|
||||
sysGiftConfigService.updateGift(param);
|
||||
}
|
||||
|
||||
@OpsOperationReqLog(value = "新增礼物信息")
|
||||
@PostMapping
|
||||
public void addGift(@RequestBody SysGiftConfigCO param) {
|
||||
param.setCreateUser(getReqUserId());
|
||||
param.setDel(Boolean.TRUE);
|
||||
sysGiftConfigService.addGift(param);
|
||||
}
|
||||
|
||||
/**
|
||||
* 上下架礼物.
|
||||
*/
|
||||
@OpsOperationReqLog(value = "新增礼物信息")
|
||||
@PostMapping
|
||||
public void addGift(@RequestBody SysGiftConfigCO param) {
|
||||
param.setCreateUser(getReqUserId());
|
||||
param.setDel(Boolean.TRUE);
|
||||
sysGiftConfigService.addGift(param);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量追加当前平台所有礼物区域.
|
||||
*/
|
||||
@OpsOperationReqLog(value = "批量追加礼物区域")
|
||||
@PostMapping("/regions/add-all")
|
||||
public void addAllGiftRegion(@RequestBody GiftRegionAddCmd param) {
|
||||
sysGiftConfigService.addAllGiftRegion(param);
|
||||
}
|
||||
|
||||
/**
|
||||
* 兼容旧前端入口,实际逻辑仍然是追加区域.
|
||||
*/
|
||||
@OpsOperationReqLog(value = "批量追加礼物区域")
|
||||
@PostMapping("/regions/transfer-all")
|
||||
public void addAllGiftRegionCompatible(@RequestBody GiftRegionAddCmd param) {
|
||||
sysGiftConfigService.addAllGiftRegion(param);
|
||||
}
|
||||
|
||||
/**
|
||||
* 上下架礼物.
|
||||
*/
|
||||
@GetMapping("/switch/{id}/{status}")
|
||||
public void deleteGift(@PathVariable("id") Long id,
|
||||
@PathVariable("status") Boolean status) {
|
||||
|
||||
@ -3,9 +3,10 @@ package com.red.circle.console.app.service.app.sys;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.red.circle.common.business.core.ImageSizeConst;
|
||||
import com.red.circle.console.app.convertor.sys.GiftAppConvertor;
|
||||
import com.red.circle.console.app.dto.clienobject.sys.SysGiftConfigCO;
|
||||
import com.red.circle.console.app.dto.cmd.app.sys.GiftConsoleQryCmd;
|
||||
import com.red.circle.console.app.convertor.sys.GiftAppConvertor;
|
||||
import com.red.circle.console.app.dto.clienobject.sys.SysGiftConfigCO;
|
||||
import com.red.circle.console.app.dto.cmd.app.sys.GiftConsoleQryCmd;
|
||||
import com.red.circle.console.app.dto.cmd.app.sys.GiftRegionAddCmd;
|
||||
import com.red.circle.console.infra.enums.sys.SysGiftTypeEnum;
|
||||
import com.red.circle.console.inner.error.ConsoleErrorCode;
|
||||
import com.red.circle.external.inner.endpoint.oss.OssServiceClient;
|
||||
@ -155,15 +156,31 @@ public class SysGiftConfigServiceImpl implements SysGiftConfigService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GiftConfigDTO> listByTabV2(GiftConsoleQryCmd query) {
|
||||
return ResponseAssert.requiredSuccess(
|
||||
giftConfigClient.listByTabV2(giftAppConvertor.toGiftQryCmd(query)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysGiftConfigCO> listByExpiredTime(Timestamp now) {
|
||||
return giftAppConvertor.toSysGiftConfigCOList(ResponseAssert.requiredSuccess(giftConfigClient.listByExpiredTime(now)));
|
||||
}
|
||||
public List<GiftConfigDTO> listByTabV2(GiftConsoleQryCmd query) {
|
||||
return ResponseAssert.requiredSuccess(
|
||||
giftConfigClient.listByTabV2(giftAppConvertor.toGiftQryCmd(query)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addAllGiftRegion(GiftRegionAddCmd param) {
|
||||
ResponseAssert.notNull(GiftErrorCode.BAD_REQUEST, param);
|
||||
ResponseAssert.isTrue(GiftErrorCode.BAD_REQUEST, StringUtils.isNotBlank(param.getSysOrigin()));
|
||||
ResponseAssert.isTrue(GiftErrorCode.BAD_REQUEST, StringUtils.isNotBlank(param.getRegionId()));
|
||||
|
||||
Map<String, String> mapRegion = ResponseAssert.requiredSuccess(
|
||||
regionConfigClient.mapRegionNameBySysOrigin(param.getSysOrigin()));
|
||||
ResponseAssert.isTrue(GiftErrorCode.BAD_REQUEST, mapRegion.containsKey(param.getRegionId()));
|
||||
|
||||
ResponseAssert.isTrue(CommonErrorCode.UPDATE_FAILURE,
|
||||
ResponseAssert.requiredSuccess(giftConfigClient.addAllGiftRegion(
|
||||
param.getSysOrigin(), param.getRegionId())));
|
||||
giftConfigClient.removeGiftCache();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysGiftConfigCO> listByExpiredTime(Timestamp now) {
|
||||
return giftAppConvertor.toSysGiftConfigCOList(ResponseAssert.requiredSuccess(giftConfigClient.listByExpiredTime(now)));
|
||||
}
|
||||
|
||||
private Function<GiftConfigDTO, SysGiftConfigCO> getGiftConfigVOFunction(
|
||||
Map<String, String> mapRegion, Map<Long, UserProfileDTO> userMap) {
|
||||
|
||||
@ -0,0 +1,27 @@
|
||||
package com.red.circle.console.app.dto.cmd.app.sys;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 礼物区域批量追加参数.
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class GiftRegionAddCmd implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 归属系统.
|
||||
*/
|
||||
private String sysOrigin;
|
||||
|
||||
/**
|
||||
* 要追加的区域ID.
|
||||
*/
|
||||
private String regionId;
|
||||
}
|
||||
@ -1,7 +1,8 @@
|
||||
package com.red.circle.console.app.service.app.sys;
|
||||
|
||||
import com.red.circle.console.app.dto.clienobject.sys.SysGiftConfigCO;
|
||||
import com.red.circle.console.app.dto.cmd.app.sys.GiftConsoleQryCmd;
|
||||
import com.red.circle.console.app.dto.clienobject.sys.SysGiftConfigCO;
|
||||
import com.red.circle.console.app.dto.cmd.app.sys.GiftRegionAddCmd;
|
||||
import com.red.circle.console.app.dto.cmd.app.sys.GiftConsoleQryCmd;
|
||||
import com.red.circle.framework.dto.PageResult;
|
||||
import com.red.circle.other.inner.model.dto.material.GiftConfigDTO;
|
||||
import java.sql.Timestamp;
|
||||
@ -54,10 +55,15 @@ public interface SysGiftConfigService {
|
||||
*/
|
||||
void pushPairCpGiveGiftId(Long giftId, String sysOrigin);
|
||||
|
||||
/**
|
||||
* 礼物列表.
|
||||
*/
|
||||
List<GiftConfigDTO> listByTabV2(GiftConsoleQryCmd query);
|
||||
|
||||
List<SysGiftConfigCO> listByExpiredTime(Timestamp now);
|
||||
}
|
||||
/**
|
||||
* 礼物列表.
|
||||
*/
|
||||
List<GiftConfigDTO> listByTabV2(GiftConsoleQryCmd query);
|
||||
|
||||
/**
|
||||
* 批量追加当前平台所有礼物区域.
|
||||
*/
|
||||
void addAllGiftRegion(GiftRegionAddCmd param);
|
||||
|
||||
List<SysGiftConfigCO> listByExpiredTime(Timestamp now);
|
||||
}
|
||||
|
||||
@ -41,6 +41,7 @@ import org.springframework.stereotype.Service;
|
||||
public class ImGroupClientServiceImpl implements ImGroupClientService {
|
||||
|
||||
private static final Integer GROUP_ALREADY_EXISTS_ERROR_CODE = 10025;
|
||||
private static final Integer GROUP_ALREADY_USED_ERROR_CODE = 10021;
|
||||
|
||||
private final RcMessageProperties rcMessageProperties;
|
||||
private final ImGroupMemberService imGroupMemberService;
|
||||
@ -179,8 +180,9 @@ public class ImGroupClientServiceImpl implements ImGroupClientService {
|
||||
if (Objects.equals(errorCode, 0)) {
|
||||
return true;
|
||||
}
|
||||
if (Objects.equals(errorCode, GROUP_ALREADY_EXISTS_ERROR_CODE)) {
|
||||
log.warn("createAVChatRoomGroup duplicate groupId={}, treat as success", cmd.getGroupId());
|
||||
if (isGroupAlreadyExists(errorCode, response)) {
|
||||
log.warn("createAVChatRoomGroup duplicate groupId={}, errorCode={}, treat as success",
|
||||
cmd.getGroupId(), errorCode);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -212,6 +214,36 @@ public class ImGroupClientServiceImpl implements ImGroupClientService {
|
||||
}
|
||||
}
|
||||
|
||||
boolean isGroupAlreadyExists(Integer errorCode, String res) {
|
||||
if (Objects.equals(errorCode, GROUP_ALREADY_EXISTS_ERROR_CODE)
|
||||
|| Objects.equals(errorCode, GROUP_ALREADY_USED_ERROR_CODE)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
String errorInfo = parseErrorInfo(res);
|
||||
if (StringUtils.isBlank(errorInfo)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
String normalizedErrorInfo = errorInfo.toLowerCase();
|
||||
return normalizedErrorInfo.contains("group id in use")
|
||||
|| normalizedErrorInfo.contains("group id has been used");
|
||||
}
|
||||
|
||||
String parseErrorInfo(String res) {
|
||||
try {
|
||||
JsonObject jsonObject = JsonParser.parseString(res).getAsJsonObject();
|
||||
if (Objects.isNull(jsonObject) || !jsonObject.has("ErrorInfo")
|
||||
|| jsonObject.get("ErrorInfo").isJsonNull()) {
|
||||
return null;
|
||||
}
|
||||
return jsonObject.get("ErrorInfo").getAsString();
|
||||
} catch (Exception ex) {
|
||||
log.warn("parseErrorInfo fail res={}", res, ex);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
boolean recoverRoomGroup(String groupId) {
|
||||
String normalizedGroupId = Objects.isNull(groupId) ? null : groupId.trim();
|
||||
if (!isRecoverableRoomGroupId(normalizedGroupId)) {
|
||||
|
||||
@ -94,6 +94,56 @@ class ImGroupClientServiceImplTest {
|
||||
assertTrue(created);
|
||||
}
|
||||
|
||||
@Test
|
||||
void createAvChatRoomGroupShouldTreatUsedGroupAsSuccess() {
|
||||
ImGroupManagerService imGroupManagerService = mock(ImGroupManagerService.class);
|
||||
@SuppressWarnings("unchecked")
|
||||
RcHttpClient.ResponseMono<String> responseMono = mock(RcHttpClient.ResponseMono.class);
|
||||
when(imGroupManagerService.createGroup(any())).thenReturn(responseMono);
|
||||
when(responseMono.block())
|
||||
.thenReturn("{\"ErrorCode\":10021,\"ErrorInfo\":\"group id has been used!\"}");
|
||||
|
||||
ImGroupClientServiceImpl service = new ImGroupClientServiceImpl(
|
||||
mock(RcMessageProperties.class),
|
||||
mock(ImGroupMemberService.class),
|
||||
mock(ImGroupMessageService.class),
|
||||
imGroupManagerService,
|
||||
mock(RoomManagerClient.class)
|
||||
);
|
||||
|
||||
boolean created = service.createAVChatRoomGroup(new CreateGroupCmd()
|
||||
.setOwnerAccount("2048587544039321602")
|
||||
.setGroupId("1001859")
|
||||
.setName("10025"));
|
||||
|
||||
assertTrue(created);
|
||||
}
|
||||
|
||||
@Test
|
||||
void createAvChatRoomGroupShouldTreatDuplicateErrorInfoAsSuccess() {
|
||||
ImGroupManagerService imGroupManagerService = mock(ImGroupManagerService.class);
|
||||
@SuppressWarnings("unchecked")
|
||||
RcHttpClient.ResponseMono<String> responseMono = mock(RcHttpClient.ResponseMono.class);
|
||||
when(imGroupManagerService.createGroup(any())).thenReturn(responseMono);
|
||||
when(responseMono.block())
|
||||
.thenReturn("{\"ErrorCode\":99999,\"ErrorInfo\":\"group id has been used!\"}");
|
||||
|
||||
ImGroupClientServiceImpl service = new ImGroupClientServiceImpl(
|
||||
mock(RcMessageProperties.class),
|
||||
mock(ImGroupMemberService.class),
|
||||
mock(ImGroupMessageService.class),
|
||||
imGroupManagerService,
|
||||
mock(RoomManagerClient.class)
|
||||
);
|
||||
|
||||
boolean created = service.createAVChatRoomGroup(new CreateGroupCmd()
|
||||
.setOwnerAccount("2048587544039321602")
|
||||
.setGroupId("1001859")
|
||||
.setName("10025"));
|
||||
|
||||
assertTrue(created);
|
||||
}
|
||||
|
||||
private static final class TestableImGroupClientServiceImpl extends ImGroupClientServiceImpl {
|
||||
|
||||
private boolean createResult;
|
||||
|
||||
@ -117,14 +117,19 @@ public interface GiftConfigService extends BaseService<GiftConfig> {
|
||||
*/
|
||||
Boolean updateGift(GiftConfig giftConfigDTO);
|
||||
|
||||
/**
|
||||
* 上下架礼物.
|
||||
*/
|
||||
Boolean switchDelStatus(Long id, Boolean status);
|
||||
|
||||
/**
|
||||
* 礼物列表.
|
||||
*/
|
||||
/**
|
||||
* 上下架礼物.
|
||||
*/
|
||||
Boolean switchDelStatus(Long id, Boolean status);
|
||||
|
||||
/**
|
||||
* 批量追加当前平台所有礼物区域.
|
||||
*/
|
||||
Boolean addAllGiftRegion(String sysOrigin, String regionId);
|
||||
|
||||
/**
|
||||
* 礼物列表.
|
||||
*/
|
||||
List<GiftConfig> listByTab(String sysOrigin, String giftTab);
|
||||
|
||||
/**
|
||||
|
||||
@ -15,11 +15,12 @@ import com.red.circle.other.inner.model.cmd.sys.GiftQryCmd;
|
||||
import com.red.circle.tool.core.collection.CollectionUtils;
|
||||
import com.red.circle.tool.core.num.NumUtils;
|
||||
import com.red.circle.tool.core.text.StringUtils;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
@ -236,14 +237,55 @@ public class GiftConfigServiceImpl extends BaseServiceImpl<GiftConfigDAO, GiftCo
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean switchDelStatus(Long id, Boolean status) {
|
||||
return update().set(GiftConfig::getDel, status)
|
||||
.eq(GiftConfig::getId, id)
|
||||
.execute();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GiftConfig> listByTab(String sysOrigin, String giftTab) {
|
||||
public Boolean switchDelStatus(Long id, Boolean status) {
|
||||
return update().set(GiftConfig::getDel, status)
|
||||
.eq(GiftConfig::getId, id)
|
||||
.execute();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean addAllGiftRegion(String sysOrigin, String regionId) {
|
||||
if (StringUtils.isBlank(sysOrigin) || StringUtils.isBlank(regionId)) {
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
List<GiftConfig> giftConfigs = query()
|
||||
.select(GiftConfig::getId, GiftConfig::getRegions)
|
||||
.eq(GiftConfig::getSysOrigin, sysOrigin)
|
||||
.list();
|
||||
if (CollectionUtils.isEmpty(giftConfigs)) {
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
List<GiftConfig> needUpdateGifts = giftConfigs.stream()
|
||||
.map(giftConfig -> buildGiftRegionAppend(giftConfig, regionId))
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toList());
|
||||
return CollectionUtils.isEmpty(needUpdateGifts) || updateBatchById(needUpdateGifts);
|
||||
}
|
||||
|
||||
private GiftConfig buildGiftRegionAppend(GiftConfig giftConfig, String regionId) {
|
||||
String nextRegions = appendRegion(giftConfig.getRegions(), regionId);
|
||||
if (Objects.equals(nextRegions, giftConfig.getRegions())) {
|
||||
return null;
|
||||
}
|
||||
return new GiftConfig()
|
||||
.setId(giftConfig.getId())
|
||||
.setRegions(nextRegions);
|
||||
}
|
||||
|
||||
private String appendRegion(String regions, String regionId) {
|
||||
if (StringUtils.isBlank(regions)) {
|
||||
return regionId;
|
||||
}
|
||||
LinkedHashSet<String> regionSet = Stream.of(regions.split(","))
|
||||
.map(String::trim)
|
||||
.filter(StringUtils::isNotBlank)
|
||||
.collect(Collectors.toCollection(LinkedHashSet::new));
|
||||
return regionSet.add(regionId) ? String.join(",", regionSet) : regions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GiftConfig> listByTab(String sysOrigin, String giftTab) {
|
||||
return Optional.ofNullable(query()
|
||||
.eq(GiftConfig::getSysOrigin, sysOrigin)
|
||||
.eq(GiftConfig::getGiftTab, giftTab)
|
||||
|
||||
@ -84,12 +84,17 @@ public class GiftConfigClientEndpoint implements GiftConfigClientApi {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultResponse<Boolean> switchDelStatus(Long id, Boolean status) {
|
||||
return ResultResponse.success(giftConfigClientService.switchDelStatus(id, status));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultResponse<List<GiftConfigDTO>> listByTab(String sysOrigin, String giftTab) {
|
||||
public ResultResponse<Boolean> switchDelStatus(Long id, Boolean status) {
|
||||
return ResultResponse.success(giftConfigClientService.switchDelStatus(id, status));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultResponse<Boolean> addAllGiftRegion(String sysOrigin, String regionId) {
|
||||
return ResultResponse.success(giftConfigClientService.addAllGiftRegion(sysOrigin, regionId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultResponse<List<GiftConfigDTO>> listByTab(String sysOrigin, String giftTab) {
|
||||
return ResultResponse.success(giftConfigClientService.listByTab(sysOrigin, giftTab));
|
||||
}
|
||||
|
||||
|
||||
@ -68,14 +68,19 @@ public interface GiftConfigClientService {
|
||||
*/
|
||||
Boolean saveGift(GiftConfigDTO giftConfig);
|
||||
|
||||
/**
|
||||
* 上下架礼物.
|
||||
*/
|
||||
Boolean switchDelStatus(Long id, Boolean status);
|
||||
|
||||
/**
|
||||
* 礼物列表.
|
||||
*/
|
||||
/**
|
||||
* 上下架礼物.
|
||||
*/
|
||||
Boolean switchDelStatus(Long id, Boolean status);
|
||||
|
||||
/**
|
||||
* 批量追加当前平台所有礼物区域.
|
||||
*/
|
||||
Boolean addAllGiftRegion(String sysOrigin, String regionId);
|
||||
|
||||
/**
|
||||
* 礼物列表.
|
||||
*/
|
||||
List<GiftConfigDTO> listByTab(String sysOrigin, String giftTab);
|
||||
|
||||
/**
|
||||
|
||||
@ -86,12 +86,17 @@ public class GiftConfigClientServiceImpl implements GiftConfigClientService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean switchDelStatus(Long id, Boolean status) {
|
||||
return giftConfigService.switchDelStatus(id, status);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GiftConfigDTO> listByTab(String sysOrigin, String giftTab) {
|
||||
public Boolean switchDelStatus(Long id, Boolean status) {
|
||||
return giftConfigService.switchDelStatus(id, status);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean addAllGiftRegion(String sysOrigin, String regionId) {
|
||||
return giftConfigService.addAllGiftRegion(sysOrigin, regionId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GiftConfigDTO> listByTab(String sysOrigin, String giftTab) {
|
||||
return giftInnerConvertor.toListGiftConfigDTO(giftConfigService.listByTab(sysOrigin, giftTab));
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user