礼物区域追加
This commit is contained in:
parent
8e4e8f5db2
commit
82e8dc0bfe
@ -38,14 +38,20 @@
|
|||||||
<artifactId>spring-boot-starter-jdbc</artifactId>
|
<artifactId>spring-boot-starter-jdbc</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>mysql</groupId>
|
<groupId>mysql</groupId>
|
||||||
<artifactId>mysql-connector-java</artifactId>
|
<artifactId>mysql-connector-java</artifactId>
|
||||||
<version>${mysql-connector-java.version}</version>
|
<version>${mysql-connector-java.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.yaml</groupId>
|
<groupId>p6spy</groupId>
|
||||||
|
<artifactId>p6spy</artifactId>
|
||||||
|
<version>${p6spy.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.yaml</groupId>
|
||||||
<artifactId>snakeyaml</artifactId>
|
<artifactId>snakeyaml</artifactId>
|
||||||
<version>${snakeyaml.version}</version>
|
<version>${snakeyaml.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
@ -113,10 +119,11 @@
|
|||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven.deploy.skip>true</maven.deploy.skip>
|
<maven.deploy.skip>true</maven.deploy.skip>
|
||||||
<elasticjob.version>3.0.4</elasticjob.version>
|
<elasticjob.version>3.0.4</elasticjob.version>
|
||||||
<snakeyaml.version>2.2</snakeyaml.version>
|
<snakeyaml.version>2.2</snakeyaml.version>
|
||||||
<mysql-connector-java.version>8.0.33</mysql-connector-java.version>
|
<mysql-connector-java.version>8.0.33</mysql-connector-java.version>
|
||||||
</properties>
|
<p6spy.version>3.8.5</p6spy.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>rc-dependencies</artifactId>
|
<artifactId>rc-dependencies</artifactId>
|
||||||
|
|||||||
@ -23,5 +23,5 @@ feign:
|
|||||||
|
|
||||||
elasticjob:
|
elasticjob:
|
||||||
reg-center:
|
reg-center:
|
||||||
server-lists: 127.0.0.1:2181
|
server-lists: zookeeper:2181
|
||||||
namespace: rc-scheduling-local
|
namespace: rc-scheduling-local
|
||||||
|
|||||||
@ -27,6 +27,10 @@ spring:
|
|||||||
config:
|
config:
|
||||||
import:
|
import:
|
||||||
- optional:nacos:application.@register.file-extension@
|
- 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@
|
- optional:nacos:framework-config.@register.file-extension@?refresh=true&group=@config.group.common@
|
||||||
|
|
||||||
logging:
|
logging:
|
||||||
|
|||||||
@ -25,12 +25,14 @@ spring:
|
|||||||
cache:
|
cache:
|
||||||
ttl: 5s
|
ttl: 5s
|
||||||
|
|
||||||
config:
|
config:
|
||||||
import:
|
import:
|
||||||
- optional:nacos:application.@register.file-extension@?refresh=true&group=@artifactId@
|
- 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: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:${spring.application.name}-${spring-profile.active}.@register.file-extension@?refresh=true&group=@artifactId@
|
||||||
- optional:nacos:rocketmq.@register.file-extension@?group=@config.group.common@
|
- 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:external.@register.file-extension@?refresh=true&group=@config.group.common@
|
||||||
- optional:nacos:framework-config.@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")
|
@PostMapping("/saveGift")
|
||||||
ResultResponse<Boolean> saveGift(@RequestBody GiftConfigDTO giftConfig);
|
ResultResponse<Boolean> saveGift(@RequestBody GiftConfigDTO giftConfig);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 上下架礼物.
|
* 上下架礼物.
|
||||||
*/
|
*/
|
||||||
@GetMapping("/switchDelStatus")
|
@GetMapping("/switchDelStatus")
|
||||||
ResultResponse<Boolean> switchDelStatus(@RequestParam("id") Long id,
|
ResultResponse<Boolean> switchDelStatus(@RequestParam("id") Long id,
|
||||||
@RequestParam("status") Boolean status);
|
@RequestParam("status") Boolean status);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 礼物列表.
|
* 批量追加当前平台所有礼物区域.
|
||||||
*/
|
*/
|
||||||
|
@PostMapping("/addAllGiftRegion")
|
||||||
|
ResultResponse<Boolean> addAllGiftRegion(@RequestParam("sysOrigin") String sysOrigin,
|
||||||
|
@RequestParam("regionId") String regionId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 礼物列表.
|
||||||
|
*/
|
||||||
@GetMapping("/listByTab")
|
@GetMapping("/listByTab")
|
||||||
ResultResponse<List<GiftConfigDTO>> listByTab(@RequestParam("sysOrigin") String sysOrigin,
|
ResultResponse<List<GiftConfigDTO>> listByTab(@RequestParam("sysOrigin") String sysOrigin,
|
||||||
@RequestParam("giftTab") String giftTab);
|
@RequestParam("giftTab") String giftTab);
|
||||||
|
|||||||
@ -1,8 +1,9 @@
|
|||||||
package com.red.circle.console.adapter.app.sys;
|
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.clienobject.sys.SysGiftConfigCO;
|
||||||
import com.red.circle.console.app.dto.cmd.app.sys.GiftConsoleQryCmd;
|
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.app.service.app.sys.SysGiftConfigService;
|
||||||
import com.red.circle.console.infra.annotations.OpsOperationReqLog;
|
import com.red.circle.console.infra.annotations.OpsOperationReqLog;
|
||||||
import com.red.circle.framework.dto.PageResult;
|
import com.red.circle.framework.dto.PageResult;
|
||||||
@ -57,17 +58,35 @@ public class SysGiftConfigRestController extends BaseController {
|
|||||||
sysGiftConfigService.updateGift(param);
|
sysGiftConfigService.updateGift(param);
|
||||||
}
|
}
|
||||||
|
|
||||||
@OpsOperationReqLog(value = "新增礼物信息")
|
@OpsOperationReqLog(value = "新增礼物信息")
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public void addGift(@RequestBody SysGiftConfigCO param) {
|
public void addGift(@RequestBody SysGiftConfigCO param) {
|
||||||
param.setCreateUser(getReqUserId());
|
param.setCreateUser(getReqUserId());
|
||||||
param.setDel(Boolean.TRUE);
|
param.setDel(Boolean.TRUE);
|
||||||
sysGiftConfigService.addGift(param);
|
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}")
|
@GetMapping("/switch/{id}/{status}")
|
||||||
public void deleteGift(@PathVariable("id") Long id,
|
public void deleteGift(@PathVariable("id") Long id,
|
||||||
@PathVariable("status") Boolean status) {
|
@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.Lists;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.red.circle.common.business.core.ImageSizeConst;
|
import com.red.circle.common.business.core.ImageSizeConst;
|
||||||
import com.red.circle.console.app.convertor.sys.GiftAppConvertor;
|
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.clienobject.sys.SysGiftConfigCO;
|
||||||
import com.red.circle.console.app.dto.cmd.app.sys.GiftConsoleQryCmd;
|
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.infra.enums.sys.SysGiftTypeEnum;
|
||||||
import com.red.circle.console.inner.error.ConsoleErrorCode;
|
import com.red.circle.console.inner.error.ConsoleErrorCode;
|
||||||
import com.red.circle.external.inner.endpoint.oss.OssServiceClient;
|
import com.red.circle.external.inner.endpoint.oss.OssServiceClient;
|
||||||
@ -155,15 +156,31 @@ public class SysGiftConfigServiceImpl implements SysGiftConfigService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<GiftConfigDTO> listByTabV2(GiftConsoleQryCmd query) {
|
public List<GiftConfigDTO> listByTabV2(GiftConsoleQryCmd query) {
|
||||||
return ResponseAssert.requiredSuccess(
|
return ResponseAssert.requiredSuccess(
|
||||||
giftConfigClient.listByTabV2(giftAppConvertor.toGiftQryCmd(query)));
|
giftConfigClient.listByTabV2(giftAppConvertor.toGiftQryCmd(query)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SysGiftConfigCO> listByExpiredTime(Timestamp now) {
|
public void addAllGiftRegion(GiftRegionAddCmd param) {
|
||||||
return giftAppConvertor.toSysGiftConfigCOList(ResponseAssert.requiredSuccess(giftConfigClient.listByExpiredTime(now)));
|
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(
|
private Function<GiftConfigDTO, SysGiftConfigCO> getGiftConfigVOFunction(
|
||||||
Map<String, String> mapRegion, Map<Long, UserProfileDTO> userMap) {
|
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;
|
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.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.dto.cmd.app.sys.GiftConsoleQryCmd;
|
||||||
import com.red.circle.framework.dto.PageResult;
|
import com.red.circle.framework.dto.PageResult;
|
||||||
import com.red.circle.other.inner.model.dto.material.GiftConfigDTO;
|
import com.red.circle.other.inner.model.dto.material.GiftConfigDTO;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
@ -54,10 +55,15 @@ public interface SysGiftConfigService {
|
|||||||
*/
|
*/
|
||||||
void pushPairCpGiveGiftId(Long giftId, String sysOrigin);
|
void pushPairCpGiveGiftId(Long giftId, String sysOrigin);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 礼物列表.
|
* 礼物列表.
|
||||||
*/
|
*/
|
||||||
List<GiftConfigDTO> listByTabV2(GiftConsoleQryCmd query);
|
List<GiftConfigDTO> listByTabV2(GiftConsoleQryCmd query);
|
||||||
|
|
||||||
List<SysGiftConfigCO> listByExpiredTime(Timestamp now);
|
/**
|
||||||
}
|
* 批量追加当前平台所有礼物区域.
|
||||||
|
*/
|
||||||
|
void addAllGiftRegion(GiftRegionAddCmd param);
|
||||||
|
|
||||||
|
List<SysGiftConfigCO> listByExpiredTime(Timestamp now);
|
||||||
|
}
|
||||||
|
|||||||
@ -41,6 +41,7 @@ import org.springframework.stereotype.Service;
|
|||||||
public class ImGroupClientServiceImpl implements ImGroupClientService {
|
public class ImGroupClientServiceImpl implements ImGroupClientService {
|
||||||
|
|
||||||
private static final Integer GROUP_ALREADY_EXISTS_ERROR_CODE = 10025;
|
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 RcMessageProperties rcMessageProperties;
|
||||||
private final ImGroupMemberService imGroupMemberService;
|
private final ImGroupMemberService imGroupMemberService;
|
||||||
@ -179,8 +180,9 @@ public class ImGroupClientServiceImpl implements ImGroupClientService {
|
|||||||
if (Objects.equals(errorCode, 0)) {
|
if (Objects.equals(errorCode, 0)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (Objects.equals(errorCode, GROUP_ALREADY_EXISTS_ERROR_CODE)) {
|
if (isGroupAlreadyExists(errorCode, response)) {
|
||||||
log.warn("createAVChatRoomGroup duplicate groupId={}, treat as success", cmd.getGroupId());
|
log.warn("createAVChatRoomGroup duplicate groupId={}, errorCode={}, treat as success",
|
||||||
|
cmd.getGroupId(), errorCode);
|
||||||
return true;
|
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) {
|
boolean recoverRoomGroup(String groupId) {
|
||||||
String normalizedGroupId = Objects.isNull(groupId) ? null : groupId.trim();
|
String normalizedGroupId = Objects.isNull(groupId) ? null : groupId.trim();
|
||||||
if (!isRecoverableRoomGroupId(normalizedGroupId)) {
|
if (!isRecoverableRoomGroupId(normalizedGroupId)) {
|
||||||
|
|||||||
@ -94,6 +94,56 @@ class ImGroupClientServiceImplTest {
|
|||||||
assertTrue(created);
|
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 static final class TestableImGroupClientServiceImpl extends ImGroupClientServiceImpl {
|
||||||
|
|
||||||
private boolean createResult;
|
private boolean createResult;
|
||||||
|
|||||||
@ -117,14 +117,19 @@ public interface GiftConfigService extends BaseService<GiftConfig> {
|
|||||||
*/
|
*/
|
||||||
Boolean updateGift(GiftConfig giftConfigDTO);
|
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);
|
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.collection.CollectionUtils;
|
||||||
import com.red.circle.tool.core.num.NumUtils;
|
import com.red.circle.tool.core.num.NumUtils;
|
||||||
import com.red.circle.tool.core.text.StringUtils;
|
import com.red.circle.tool.core.text.StringUtils;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.Map;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@ -236,14 +237,55 @@ public class GiftConfigServiceImpl extends BaseServiceImpl<GiftConfigDAO, GiftCo
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean switchDelStatus(Long id, Boolean status) {
|
public Boolean switchDelStatus(Long id, Boolean status) {
|
||||||
return update().set(GiftConfig::getDel, status)
|
return update().set(GiftConfig::getDel, status)
|
||||||
.eq(GiftConfig::getId, id)
|
.eq(GiftConfig::getId, id)
|
||||||
.execute();
|
.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<GiftConfig> listByTab(String sysOrigin, String giftTab) {
|
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()
|
return Optional.ofNullable(query()
|
||||||
.eq(GiftConfig::getSysOrigin, sysOrigin)
|
.eq(GiftConfig::getSysOrigin, sysOrigin)
|
||||||
.eq(GiftConfig::getGiftTab, giftTab)
|
.eq(GiftConfig::getGiftTab, giftTab)
|
||||||
|
|||||||
@ -84,12 +84,17 @@ public class GiftConfigClientEndpoint implements GiftConfigClientApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResultResponse<Boolean> switchDelStatus(Long id, Boolean status) {
|
public ResultResponse<Boolean> switchDelStatus(Long id, Boolean status) {
|
||||||
return ResultResponse.success(giftConfigClientService.switchDelStatus(id, status));
|
return ResultResponse.success(giftConfigClientService.switchDelStatus(id, status));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResultResponse<List<GiftConfigDTO>> listByTab(String sysOrigin, String giftTab) {
|
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));
|
return ResultResponse.success(giftConfigClientService.listByTab(sysOrigin, giftTab));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -68,14 +68,19 @@ public interface GiftConfigClientService {
|
|||||||
*/
|
*/
|
||||||
Boolean saveGift(GiftConfigDTO giftConfig);
|
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);
|
List<GiftConfigDTO> listByTab(String sysOrigin, String giftTab);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -86,12 +86,17 @@ public class GiftConfigClientServiceImpl implements GiftConfigClientService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean switchDelStatus(Long id, Boolean status) {
|
public Boolean switchDelStatus(Long id, Boolean status) {
|
||||||
return giftConfigService.switchDelStatus(id, status);
|
return giftConfigService.switchDelStatus(id, status);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<GiftConfigDTO> listByTab(String sysOrigin, String giftTab) {
|
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));
|
return giftInnerConvertor.toListGiftConfigDTO(giftConfigService.listByTab(sysOrigin, giftTab));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user