kotlin-云信-重写部分
This commit is contained in:
@@ -1,47 +0,0 @@
|
||||
package com.accompany.common.netease;
|
||||
|
||||
import com.accompany.common.netease.util.CheckSumBuilder;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.NameValuePair;
|
||||
import org.apache.http.client.entity.UrlEncodedFormEntity;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.apache.http.message.BasicNameValuePair;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public class Test {
|
||||
public static void main(String[] args) throws Exception{
|
||||
CloseableHttpClient httpClient = HttpClients.createDefault();
|
||||
String url = "https://api.netease.im/nimserver/user/create.action";
|
||||
HttpPost httpPost = new HttpPost(url);
|
||||
|
||||
String appKey = "";//NetEaseConstant.appKey;
|
||||
String appSecret = "";// NetEaseConstant.appSecret;
|
||||
String nonce = "12345";
|
||||
String curTime = String.valueOf((new Date()).getTime() / 1000L);
|
||||
String checkSum = CheckSumBuilder.getCheckSum(appSecret, nonce ,curTime);//参考 计算CheckSum的java代码
|
||||
|
||||
// 设置请求的header
|
||||
httpPost.addHeader("AppKey", appKey);
|
||||
httpPost.addHeader("Nonce", nonce);
|
||||
httpPost.addHeader("CurTime", curTime);
|
||||
httpPost.addHeader("CheckSum", checkSum);
|
||||
httpPost.addHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8");
|
||||
|
||||
// 设置请求的参数
|
||||
List<NameValuePair> nvps = new ArrayList<NameValuePair>();
|
||||
nvps.add(new BasicNameValuePair("accid", "helloworld2"));
|
||||
httpPost.setEntity(new UrlEncodedFormEntity(nvps, "utf-8"));
|
||||
|
||||
// 执行请求
|
||||
HttpResponse response = httpClient.execute(httpPost);
|
||||
|
||||
// 打印执行结果
|
||||
System.out.println(EntityUtils.toString(response.getEntity(), "utf-8"));
|
||||
}
|
||||
}
|
@@ -1,30 +1,13 @@
|
||||
package com.accompany.core.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class HttpForm {
|
||||
private String name;
|
||||
private String value;
|
||||
|
||||
public HttpForm(String name, String value) {
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public HttpForm() {
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
@@ -0,0 +1,18 @@
|
||||
package com.accompany.business.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ChatRoom {
|
||||
private Object announcement;
|
||||
private String broadcasturl;
|
||||
private String creator;
|
||||
private String ext;
|
||||
private Boolean ionotify;
|
||||
private Boolean muted;
|
||||
private String name;
|
||||
private Integer onlineusercount;
|
||||
private Integer queuelevel;
|
||||
private Integer roomid;
|
||||
private Boolean valid;
|
||||
}
|
@@ -0,0 +1,9 @@
|
||||
package com.accompany.business.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class QueryRoomStateDTO {
|
||||
private Long roomid = 0L;
|
||||
private String needOnlineUserCount = Boolean.TRUE.toString();
|
||||
}
|
@@ -1,35 +0,0 @@
|
||||
package com.accompany.business.dto
|
||||
|
||||
class QueryRoomStateDTO {
|
||||
|
||||
/**
|
||||
* 房间 id
|
||||
*/
|
||||
var roomid: Long = 0L
|
||||
|
||||
/**
|
||||
* 是否需要返回在线人数
|
||||
*/
|
||||
var needOnlineUserCount: String = true.toString()
|
||||
|
||||
}
|
||||
|
||||
|
||||
data class QueryRoomStateResponseDTO(
|
||||
val chatroom: Chatroom?,
|
||||
val code: Int?
|
||||
)
|
||||
|
||||
data class Chatroom(
|
||||
val announcement: Any?,
|
||||
val broadcasturl: String?,
|
||||
val creator: String?,
|
||||
val ext: String?,
|
||||
val ionotify: Boolean?,
|
||||
val muted: Boolean?,
|
||||
val name: String?,
|
||||
val onlineusercount: Int?,
|
||||
val queuelevel: Int?,
|
||||
val roomid: Int?,
|
||||
val valid: Boolean?
|
||||
)
|
@@ -0,0 +1,13 @@
|
||||
package com.accompany.business.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class QueryRoomStateResponseDTO {
|
||||
private ChatRoom chatroom;
|
||||
private Integer code;
|
||||
}
|
@@ -0,0 +1,33 @@
|
||||
package com.accompany.business.dto;
|
||||
|
||||
import com.accompany.core.util.JsonUtil;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 队列元素
|
||||
*/
|
||||
@Data
|
||||
public class QueueDTO {
|
||||
private String key;
|
||||
private String value;
|
||||
|
||||
public QueueDTO(String key, String value) {
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
private Long roomid = 0L;
|
||||
|
||||
private QueueValueDTO valueObject;
|
||||
|
||||
public QueueValueDTO getValueObject() {
|
||||
QueueValueDTO queueValueDTO = JsonUtil.parseToClass(value, QueueValueDTO.class);
|
||||
queueValueDTO.setPosition(Long.parseLong(key));
|
||||
return queueValueDTO;
|
||||
}
|
||||
|
||||
public String getOperator() {
|
||||
return valueObject.getUid().toString();
|
||||
}
|
||||
|
||||
}
|
@@ -1,105 +0,0 @@
|
||||
package com.accompany.business.dto
|
||||
|
||||
import com.accompany.core.util.JsonUtil
|
||||
|
||||
|
||||
/**
|
||||
* 队列元素
|
||||
*/
|
||||
class QueueDTO(val key: String, var value: String) {
|
||||
|
||||
|
||||
var roomid: Long = 0
|
||||
|
||||
val valueObject: QueueValueDTO
|
||||
get() {
|
||||
val queueValueDTO = JsonUtil.parseToClass(value, QueueValueDTO::class.java)
|
||||
queueValueDTO.position = key.toLong()
|
||||
return queueValueDTO
|
||||
}
|
||||
|
||||
val operator: String?
|
||||
get() {
|
||||
return valueObject.uid?.toString()
|
||||
}
|
||||
|
||||
/**
|
||||
* 这个新元素的提交者operator的所有聊天室连接在从该聊天室掉线或者离开该聊天室的时候,提交的元素是否需要删除。
|
||||
* true:需要删除;false:不需要删除。默认false。
|
||||
*/
|
||||
val transient: String = "true"
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 队列元素
|
||||
*/
|
||||
class QueueValueDTO{
|
||||
|
||||
/**
|
||||
* 位置,从 -1开始
|
||||
*/
|
||||
var position: Long = -100
|
||||
|
||||
/**
|
||||
* 麦上用户 id
|
||||
*/
|
||||
var uid: Long? = null
|
||||
|
||||
/**
|
||||
* 麦上用户昵称
|
||||
*/
|
||||
var nick: String? = null
|
||||
|
||||
/**
|
||||
* 麦上用户头像
|
||||
*/
|
||||
var avatar: String? = null
|
||||
|
||||
/**
|
||||
* 麦上性别
|
||||
*/
|
||||
var gender: Byte? = null
|
||||
|
||||
/**
|
||||
* 麦上相亲帽子
|
||||
*/
|
||||
var capUrl: String? = null
|
||||
|
||||
/**
|
||||
* 麦上选择位置
|
||||
*/
|
||||
var selectMicPosition: String? = null
|
||||
|
||||
/**
|
||||
* 麦上是否有选择用户
|
||||
*/
|
||||
var hasSelectUser: Boolean? = null
|
||||
|
||||
/**
|
||||
* 用户头饰
|
||||
*/
|
||||
var headWearUrl: String? = null
|
||||
|
||||
/**
|
||||
* 是否为vip席位
|
||||
*/
|
||||
var vipMic:Boolean = false
|
||||
|
||||
/**
|
||||
* 麦序光圈
|
||||
*/
|
||||
var micCircle:String?=null
|
||||
|
||||
/**
|
||||
* 麦位光圈颜色
|
||||
*/
|
||||
var micNickColor:String?=null
|
||||
|
||||
/**
|
||||
* 是否防被踢
|
||||
*/
|
||||
var preventKick:Boolean = false
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
package com.accompany.business.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class QueueListDTO {
|
||||
private Long roomid;
|
||||
|
||||
public QueueListDTO(Long roomid) {
|
||||
this.roomid = roomid;
|
||||
}
|
||||
}
|
@@ -1,26 +0,0 @@
|
||||
package com.accompany.business.dto
|
||||
|
||||
|
||||
class QueueListDTO(val roomid: Long)
|
||||
|
||||
|
||||
class QueueListResponseDTO {
|
||||
|
||||
|
||||
lateinit var desc: Desc
|
||||
|
||||
var code: Int = 0
|
||||
|
||||
class Desc {
|
||||
|
||||
var list: List<Map<String, String>> = listOf()
|
||||
|
||||
fun listDTO(): List<QueueDTO> {
|
||||
return list.map {
|
||||
QueueDTO(it.keys.first(), it[it.keys.first()] ?: error("无此key ${it.keys.first()}"))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,23 @@
|
||||
package com.accompany.business.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Data
|
||||
public class QueueListResponseDTO {
|
||||
private Desc desc;
|
||||
private int code;
|
||||
|
||||
@Data
|
||||
public static class Desc {
|
||||
private List<Map<String, String>> list;
|
||||
|
||||
public List<QueueDTO> listDTO() {
|
||||
return list.stream().map(it -> new QueueDTO(it.keySet().iterator().next(), it.get(it.keySet().iterator().next()))).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,17 @@
|
||||
package com.accompany.business.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 队列中取出元素 dto
|
||||
*/
|
||||
@Data
|
||||
public class QueuePoolDTO {
|
||||
private Long roomid;
|
||||
private String key;
|
||||
|
||||
public QueuePoolDTO(Long roomid, String key) {
|
||||
this.roomid = roomid;
|
||||
this.key = (key != null) ? key : "";
|
||||
}
|
||||
}
|
@@ -1,6 +0,0 @@
|
||||
package com.accompany.business.dto
|
||||
|
||||
/**
|
||||
* 队列中取出元素 dto
|
||||
*/
|
||||
class QueuePoolDTO(val roomid: Long, val key: String? = null)
|
@@ -0,0 +1,75 @@
|
||||
package com.accompany.business.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 队列元素
|
||||
*/
|
||||
@Data
|
||||
public class QueueValueDTO {
|
||||
/**
|
||||
* 位置,从 -1开始
|
||||
*/
|
||||
private Long position = -100L;
|
||||
|
||||
/**
|
||||
* 麦上用户 id
|
||||
*/
|
||||
private Long uid;
|
||||
|
||||
/**
|
||||
* 麦上用户昵称
|
||||
*/
|
||||
private String nick;
|
||||
|
||||
/**
|
||||
* 麦上用户头像
|
||||
*/
|
||||
private String avatar;
|
||||
|
||||
/**
|
||||
* 麦上性别
|
||||
*/
|
||||
private Byte gender;
|
||||
|
||||
/**
|
||||
* 麦上相亲帽子
|
||||
*/
|
||||
private String capUrl;
|
||||
|
||||
/**
|
||||
* 麦上选择位置
|
||||
*/
|
||||
private String selectMicPosition;
|
||||
|
||||
/**
|
||||
* 麦上是否有选择用户
|
||||
*/
|
||||
private Boolean hasSelectUser;
|
||||
|
||||
/**
|
||||
* 用户头饰
|
||||
*/
|
||||
private String headWearUrl;
|
||||
|
||||
/**
|
||||
* 是否为vip席位
|
||||
*/
|
||||
private Boolean vipMic = false;
|
||||
|
||||
/**
|
||||
* 麦序光圈
|
||||
*/
|
||||
private String micCircle;
|
||||
|
||||
/**
|
||||
* 麦位光圈颜色
|
||||
*/
|
||||
private String micNickColor;
|
||||
|
||||
/**
|
||||
* 是否防被踢
|
||||
*/
|
||||
private Boolean preventKick = false;
|
||||
}
|
||||
|
@@ -10,6 +10,7 @@
|
||||
*/
|
||||
package com.accompany.business.service.room;
|
||||
|
||||
import com.accompany.business.dto.blindDate.BlindDateRoundConnectionSuccessDTO;
|
||||
import com.accompany.business.model.room.BlindDateRoundConnectionSuccess;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
@@ -27,4 +28,6 @@ public interface IBlindDateRoundConnectionSuccessService extends IService<BlindD
|
||||
List<BlindDateRoundConnectionSuccess> listBlindDateRoundConnectionSuccessByPage(Integer page, Integer pageSize, Date startTime, Date endDateTime);
|
||||
|
||||
Integer countBlindDateRoundConnectionSuccess(Date startTime, Date endDateTime);
|
||||
|
||||
void create(BlindDateRoundConnectionSuccessDTO dto);
|
||||
}
|
||||
|
@@ -0,0 +1,13 @@
|
||||
package com.accompany.business.service.room;
|
||||
|
||||
/**
|
||||
* 麦上魅力值
|
||||
*/
|
||||
public interface MicCharmService {
|
||||
|
||||
/**
|
||||
* 根据用户 id 获取房间内麦上魅力值
|
||||
*/
|
||||
Long getByRoomUserIdAndUserId(Long roomUserId, Long userId);
|
||||
|
||||
}
|
@@ -1,15 +0,0 @@
|
||||
package com.accompany.business.service.room
|
||||
|
||||
|
||||
/**
|
||||
* 麦上魅力值
|
||||
*/
|
||||
interface MicCharmService {
|
||||
|
||||
/**
|
||||
* 根据用户 id 获取房间内麦上魅力值
|
||||
*/
|
||||
fun getByRoomUserIdAndUserId(roomUserId: Long, userId: Long): Long?
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,20 @@
|
||||
package com.accompany.business.service.room;
|
||||
|
||||
import com.accompany.business.dto.SendRoomMsgTemplate;
|
||||
|
||||
public interface PushRoomService {
|
||||
/**
|
||||
* 发送房间消息
|
||||
*/
|
||||
void sendRoomMsg(SendRoomMsgTemplate sendRoomMsgTemplate);
|
||||
|
||||
/**
|
||||
* 发送文本消息
|
||||
*/
|
||||
void sendRoomTextMsg(SendRoomMsgTemplate sendRoomMsgTemplate);
|
||||
|
||||
/**
|
||||
* 发送提示信息
|
||||
*/
|
||||
void sendTip(SendRoomMsgTemplate sendRoomMsgTemplate);
|
||||
}
|
@@ -1,22 +0,0 @@
|
||||
package com.accompany.business.service.room
|
||||
|
||||
import com.accompany.business.dto.SendRoomMsgTemplate
|
||||
|
||||
|
||||
interface PushRoomService {
|
||||
|
||||
|
||||
/**
|
||||
* 发送房间消息
|
||||
*/
|
||||
fun sendRoomMsg(sendRoomMsgTemplate: SendRoomMsgTemplate)
|
||||
|
||||
/**
|
||||
* 发送文本消息
|
||||
*/
|
||||
fun sendRoomTextMsg(sendRoomMsgTemplate: SendRoomMsgTemplate)
|
||||
|
||||
|
||||
fun sendTip(sendRoomMsgTemplate: SendRoomMsgTemplate)
|
||||
|
||||
}
|
@@ -0,0 +1,25 @@
|
||||
package com.accompany.business.service.room;
|
||||
|
||||
import com.accompany.business.dto.*;
|
||||
|
||||
public interface QueryRoomService {
|
||||
/**
|
||||
* 房间队列
|
||||
*/
|
||||
QueueListResponseDTO queueList(Long roomId);
|
||||
|
||||
/**
|
||||
* 房间状态
|
||||
*/
|
||||
QueryRoomStateResponseDTO state(QueryRoomStateDTO queryRoomStateDTO);
|
||||
|
||||
/**
|
||||
* 删除普通广播内容
|
||||
*/
|
||||
void deleteMsg(DeleteMessageDTO deleteMessageDTO);
|
||||
|
||||
/**
|
||||
* 设置管理员
|
||||
*/
|
||||
void setOperation(SetOperationDTO dto);
|
||||
}
|
@@ -1,29 +0,0 @@
|
||||
package com.accompany.business.service.room
|
||||
|
||||
import com.accompany.business.dto.*
|
||||
|
||||
|
||||
interface QueryRoomService {
|
||||
|
||||
/**
|
||||
* 房间队列
|
||||
*/
|
||||
fun queueList(roomId: Long): QueueListResponseDTO
|
||||
|
||||
/**
|
||||
* 房间状态
|
||||
*/
|
||||
fun state(queryRoomStateDTO: QueryRoomStateDTO): QueryRoomStateResponseDTO
|
||||
|
||||
/**
|
||||
* 删除普通广播内容
|
||||
*/
|
||||
fun deleteMsg(deleteMessageDTO: DeleteMessageDTO)
|
||||
|
||||
/**
|
||||
* 设置管理员
|
||||
*/
|
||||
fun setOperation(dto: SetOperationDTO)
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,19 @@
|
||||
package com.accompany.business.service.room;
|
||||
|
||||
import com.accompany.business.dto.QueueDTO;
|
||||
import com.accompany.business.dto.QueuePoolDTO;
|
||||
|
||||
/**
|
||||
* 队列 service
|
||||
*/
|
||||
public interface QueueService {
|
||||
/**
|
||||
* 插入或更新队列中的元素
|
||||
*/
|
||||
void upsert(QueueDTO dto);
|
||||
|
||||
/**
|
||||
* 队列中取出元素
|
||||
*/
|
||||
void queuePoll(QueuePoolDTO dto);
|
||||
}
|
@@ -1,22 +0,0 @@
|
||||
package com.accompany.business.service.room
|
||||
|
||||
import com.accompany.business.dto.QueueDTO
|
||||
import com.accompany.business.dto.QueuePoolDTO
|
||||
|
||||
|
||||
/**
|
||||
* 队列 service
|
||||
*/
|
||||
interface QueueService {
|
||||
|
||||
|
||||
fun upsert(dto: QueueDTO)
|
||||
|
||||
|
||||
/**
|
||||
* 队列中取出元素
|
||||
*/
|
||||
fun queuePoll(dto: QueuePoolDTO)
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,4 @@
|
||||
package com.accompany.business.service.room.impl;
|
||||
|
||||
public class BlindDateMaxGiftValueServiceImpl {
|
||||
}
|
@@ -11,7 +11,6 @@ import com.accompany.core.annotation.Lock
|
||||
import com.accompany.core.exception.ServiceException
|
||||
import com.accompany.core.model.Room
|
||||
import com.accompany.core.util.JsonUtil
|
||||
import com.sun.org.apache.xpath.internal.operations.Bool
|
||||
import org.slf4j.LoggerFactory
|
||||
import org.springframework.beans.factory.annotation.Autowired
|
||||
import org.springframework.stereotype.Service
|
||||
|
@@ -0,0 +1,99 @@
|
||||
package com.accompany.business.service.room.impl;
|
||||
|
||||
import com.accompany.business.dto.DatingNotifyInfoDTO;
|
||||
import com.accompany.business.dto.QueueDTO;
|
||||
import com.accompany.business.dto.SendRoomMsgTemplate;
|
||||
import com.accompany.business.dto.blindDate.BlindDateRoundConnectionDTO;
|
||||
import com.accompany.business.dto.blindDate.BlindDateRoundDTO;
|
||||
import com.accompany.business.model.room.BlindDateRoundConnection;
|
||||
import com.accompany.business.service.room.*;
|
||||
import com.accompany.common.config.SystemConfig;
|
||||
import com.accompany.common.constant.Attach;
|
||||
import com.accompany.common.constant.Constant;
|
||||
import com.accompany.common.utils.BeanUtil;
|
||||
import com.accompany.common.utils.JsonUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class BlindDateRoundConnectionServiceImpl implements BlindDateRoundConnectionService {
|
||||
|
||||
@Autowired
|
||||
private BlindDateService blindDateService;
|
||||
|
||||
@Autowired
|
||||
private QueryRoomService queryRoomService;
|
||||
|
||||
@Autowired
|
||||
private BlindDateRoundService blindDateRoundService;
|
||||
|
||||
@Autowired
|
||||
private PushRoomService pushRoomService;
|
||||
|
||||
@Autowired
|
||||
private IBlindDateRoundConnectionService iBlindDateRoundConnectionService;
|
||||
|
||||
@Override
|
||||
public void create(BlindDateRoundConnectionDTO dto) {
|
||||
BlindDateRoundConnection blindDateRoundConnectionModel = BeanUtil.map(dto, BlindDateRoundConnection.class);
|
||||
iBlindDateRoundConnectionService.create(blindDateRoundConnectionModel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteBySelectUserId(Long roundId, Long selectUserId) {
|
||||
iBlindDateRoundConnectionService.deleteByRoundIdAndSelectUserId(roundId, selectUserId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteByBeSelectUserId(Long roundId, Long selectUserId) {
|
||||
iBlindDateRoundConnectionService.deleteByRoundIdAndBeSelectUserId(roundId, selectUserId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyConnect(BlindDateRoundConnectionDTO dto) {
|
||||
List<DatingNotifyInfoDTO> buildNotifyDTO = blindDateService.buildNotifyDTO(dto.getBlindDateRoundId());
|
||||
buildNotifyDTO.stream()
|
||||
.filter(info -> info.getUid() == dto.getSelectUserId() && info.getTargetUid() == dto.getBeSelectedUserId())
|
||||
.findFirst()
|
||||
.ifPresent(first -> notifySingle(dto.getBlindDateRoundId(), first));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifySingle(Long roundId, DatingNotifyInfoDTO notifyDto) {
|
||||
BlindDateRoundDTO blindDateRoundDTO = blindDateRoundService.getById(roundId);
|
||||
SendRoomMsgTemplate sendRoomMsgTemplate = new SendRoomMsgTemplate();
|
||||
sendRoomMsgTemplate.setFromUserId(Long.parseLong(SystemConfig.systemMessageUid));
|
||||
sendRoomMsgTemplate.setToRoomId(blindDateRoundDTO.getRoomId());
|
||||
Attach attach = new Attach();
|
||||
attach.setData(JsonUtil.parseToString(notifyDto));
|
||||
attach.setFirst(Constant.DefineProtocol.CUSTOM_MSG_DATING);
|
||||
attach.setSecond(Constant.DefineProtocol.CUSTOM_MSG_SUB_DATING_SELECT);
|
||||
sendRoomMsgTemplate.setAttach(JsonUtil.parseToString(attach));
|
||||
pushRoomService.sendRoomMsg(sendRoomMsgTemplate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BlindDateRoundConnectionDTO> listByRoundId(Long roundId) {
|
||||
List<BlindDateRoundConnection> listByRoundId = iBlindDateRoundConnectionService.listByRoundId(roundId);
|
||||
return BeanUtil.mapList(listByRoundId, BlindDateRoundConnection.class, BlindDateRoundConnectionDTO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer position(Long roomId, Long userId) {
|
||||
List<QueueDTO> queueList = queryRoomService.queueList(roomId).getDesc().listDTO();
|
||||
Integer position = queueList.stream()
|
||||
.filter(queueDTO -> queueDTO.getValueObject().getUid().equals(userId))
|
||||
.findFirst()
|
||||
.map(QueueDTO::getKey)
|
||||
.map(Integer::valueOf)
|
||||
.orElse(null);
|
||||
log.info("查询 {} {} 的位置为 {}", userId, roomId, position);
|
||||
return position;
|
||||
}
|
||||
}
|
@@ -1,90 +0,0 @@
|
||||
package com.accompany.business.service.room.impl
|
||||
|
||||
import com.accompany.business.dto.DatingNotifyInfoDTO
|
||||
import com.accompany.business.dto.SendRoomMsgTemplate
|
||||
import com.accompany.business.model.room.BlindDateRoundConnection
|
||||
import com.accompany.business.service.room.*
|
||||
import com.accompany.common.config.SystemConfig
|
||||
import com.accompany.common.constant.Attach
|
||||
import com.accompany.common.constant.Constant
|
||||
import com.accompany.common.utils.BeanUtil
|
||||
import com.accompany.common.utils.JsonUtil
|
||||
import com.accompany.core.annotation.LogTime
|
||||
import org.slf4j.LoggerFactory
|
||||
import org.springframework.beans.factory.annotation.Autowired
|
||||
import org.springframework.stereotype.Service
|
||||
import org.springframework.transaction.annotation.Transactional
|
||||
|
||||
@Service
|
||||
@Transactional(rollbackFor = [Exception::class])
|
||||
open class BlindDateRoundConnectionServiceImpl : BlindDateRoundConnectionService {
|
||||
|
||||
private val log = LoggerFactory.getLogger(BlindDateRoundConnectionServiceImpl::class.java)
|
||||
|
||||
@Autowired
|
||||
private lateinit var blindDateService: BlindDateService
|
||||
|
||||
@Autowired
|
||||
private lateinit var queryRoomService: QueryRoomService
|
||||
|
||||
@Autowired
|
||||
private lateinit var blindDateRoundService: BlindDateRoundService
|
||||
|
||||
@Autowired
|
||||
private lateinit var pushRoomService: PushRoomService
|
||||
@Autowired
|
||||
private lateinit var iBlindDateRoundConnectionService: IBlindDateRoundConnectionService
|
||||
|
||||
|
||||
override fun create(dto: BlindDateRoundConnectionDTO) {
|
||||
val blindDateRoundConnectionModel = BeanUtil.map(dto, BlindDateRoundConnection::class.java)
|
||||
return iBlindDateRoundConnectionService.create(blindDateRoundConnectionModel)
|
||||
}
|
||||
|
||||
override fun deleteBySelectUserId(roundId: Long, selectUserId: Long) {
|
||||
iBlindDateRoundConnectionService.deleteByRoundIdAndSelectUserId(roundId, selectUserId)
|
||||
}
|
||||
|
||||
override fun deleteByBeSelectUserId(roundId: Long, selectUserId: Long) {
|
||||
iBlindDateRoundConnectionService.deleteByRoundIdAndBeSelectUserId(roundId, selectUserId)
|
||||
}
|
||||
|
||||
@LogTime
|
||||
override fun notifyConnect(dto: BlindDateRoundConnectionDTO) {
|
||||
val buildNotifyDTO = blindDateService.buildNotifyDTO(dto.blindDateRoundId)
|
||||
// 查询此次选择对象(有可能是互选导致顺序变更)
|
||||
val first = buildNotifyDTO.first { it.uid == dto.selectUserId && it.targetUid == dto.beSelectedUserId }
|
||||
notifySingle(dto.blindDateRoundId, first)
|
||||
}
|
||||
|
||||
override fun notifySingle(roundId: Long,notifyDto: DatingNotifyInfoDTO) {
|
||||
// 给此房间发通知
|
||||
val blindDateRoundDTO = blindDateRoundService.getById(roundId)
|
||||
val sendRoomMsgTemplate = SendRoomMsgTemplate()
|
||||
sendRoomMsgTemplate.fromUserId = SystemConfig.systemMessageUid.toLong()
|
||||
sendRoomMsgTemplate.toRoomId = blindDateRoundDTO.roomId
|
||||
val attach = Attach()
|
||||
attach.data = JsonUtil.parseToString(notifyDto)
|
||||
attach.first = Constant.DefineProtocol.CUSTOM_MSG_DATING
|
||||
attach.second = Constant.DefineProtocol.CUSTOM_MSG_SUB_DATING_SELECT
|
||||
sendRoomMsgTemplate.attach = JsonUtil.parseToString(attach)
|
||||
pushRoomService.sendRoomMsg(sendRoomMsgTemplate)
|
||||
}
|
||||
|
||||
|
||||
override fun listByRoundId(roundId: Long): List<BlindDateRoundConnectionDTO> {
|
||||
val listByRoundId = iBlindDateRoundConnectionService.listByRoundId(roundId)
|
||||
return BeanUtil.mapList(listByRoundId, BlindDateRoundConnection::class.java, BlindDateRoundConnectionDTO::class.java)
|
||||
}
|
||||
|
||||
@LogTime
|
||||
override fun position(roomId: Long, userId: Long): Int? {
|
||||
val queueList = queryRoomService.queueList(roomId)
|
||||
val position = queueList.desc.listDTO().firstOrNull { it.valueObject.uid == userId }?.key?.toInt()
|
||||
log.info("查询 $userId $roomId 的位置为 $position")
|
||||
return position
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,37 @@
|
||||
package com.accompany.business.service.room.impl;
|
||||
|
||||
import com.accompany.business.dto.blindDate.BlindDateRoundConnectionSuccessDTO;
|
||||
import com.accompany.business.model.room.BlindDateRoundConnectionSuccess;
|
||||
import com.accompany.business.service.room.IBlindDateRoundConnectionSuccessService;
|
||||
import com.accompany.common.utils.BeanUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class BlindDateRoundConnectionSuccessServiceImpl implements IBlindDateRoundConnectionSuccessService {
|
||||
|
||||
@Autowired
|
||||
private IBlindDateRoundConnectionSuccessService iBlindDateRoundConnectionSuccessService;
|
||||
|
||||
|
||||
@Override
|
||||
public void create(BlindDateRoundConnectionSuccessDTO dto) {
|
||||
BlindDateRoundConnectionSuccess model = BeanUtil.map(dto, BlindDateRoundConnectionSuccess.class);
|
||||
iBlindDateRoundConnectionSuccessService.save(model);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BlindDateRoundConnectionSuccessDTO> page(Long pageNo, int pageSize, Date startTime, Date endDateTime) {
|
||||
return BeanUtil.mapList(iBlindDateRoundConnectionSuccessService.listBlindDateRoundConnectionSuccessByPage(pageNo.intValue(), pageSize, startTime, endDateTime), BlindDateRoundConnectionSuccess.class, BlindDateRoundConnectionSuccessDTO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long total(Date startTime, Date endDateTime) {
|
||||
return iBlindDateRoundConnectionSuccessService.countBlindDateRoundConnectionSuccess(startTime, endDateTime).longValue();
|
||||
}
|
||||
}
|
@@ -1,33 +1,39 @@
|
||||
package com.accompany.business.service.room.impl
|
||||
package com.accompany.business.service.room.impl;
|
||||
|
||||
import com.accompany.business.model.room.BlindDateRoundConnectionSuccess
|
||||
import com.accompany.business.service.room.IBlindDateRoundConnectionSuccessService
|
||||
import com.accompany.common.utils.BeanUtil
|
||||
import org.springframework.beans.factory.annotation.Autowired
|
||||
import org.springframework.stereotype.Service
|
||||
import org.springframework.transaction.annotation.Transactional
|
||||
import java.util.*
|
||||
import com.accompany.business.model.room.BlindDateRoundConnectionSuccess;
|
||||
import com.accompany.business.service.room.IBlindDateRoundConnectionSuccessService;
|
||||
import com.accompany.common.utils.BeanUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@Transactional(rollbackFor = [Exception::class])
|
||||
open class BlindDateRoundConnectionSuccessServiceImpl : BlindDateRoundConnectionSuccessService {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class BlindDateRoundConnectionSuccessServiceImpl implements IBlindDateRoundConnectionSuccessService {
|
||||
|
||||
private final IBlindDateRoundConnectionSuccessService iBlindDateRoundConnectionSuccessService;
|
||||
|
||||
@Autowired
|
||||
private lateinit var iBlindDateRoundConnectionSuccessService: IBlindDateRoundConnectionSuccessService
|
||||
|
||||
override fun create(dto: BlindDateRoundConnectionSuccessDTO) {
|
||||
val model = BeanUtil.map(dto, BlindDateRoundConnectionSuccess::class.java)
|
||||
iBlindDateRoundConnectionSuccessService.save(model)
|
||||
public BlindDateRoundConnectionSuccessServiceImpl(IBlindDateRoundConnectionSuccessService iBlindDateRoundConnectionSuccessService) {
|
||||
this.iBlindDateRoundConnectionSuccessService = iBlindDateRoundConnectionSuccessService;
|
||||
}
|
||||
|
||||
override fun page(pageNo: Long, pageSize: Int, startTime: Date?, endDateTime: Date?): List<BlindDateRoundConnectionSuccessDTO> {
|
||||
iBlindDateRoundConnectionSuccessService.listBlindDateRoundConnectionSuccessByPage(pageNo.toInt(), pageSize, startTime, endDateTime)
|
||||
.let { return BeanUtil.mapList(it, BlindDateRoundConnectionSuccess::class.java, BlindDateRoundConnectionSuccessDTO::class.java) }
|
||||
@Override
|
||||
public void create(BlindDateRoundConnectionSuccessDTO dto) {
|
||||
BlindDateRoundConnectionSuccess model = BeanUtil.map(dto, BlindDateRoundConnectionSuccess.class);
|
||||
iBlindDateRoundConnectionSuccessService.save(model);
|
||||
}
|
||||
|
||||
override fun total(startTime: Date?, endDateTime: Date?): Long {
|
||||
return iBlindDateRoundConnectionSuccessService.countBlindDateRoundConnectionSuccess(startTime, endDateTime).toLong()
|
||||
@Override
|
||||
public List<BlindDateRoundConnectionSuccessDTO> page(Long pageNo, int pageSize, Date startTime, Date endDateTime) {
|
||||
return BeanUtil.mapList(iBlindDateRoundConnectionSuccessService.listBlindDateRoundConnectionSuccessByPage(pageNo.intValue(), pageSize, startTime, endDateTime), BlindDateRoundConnectionSuccess.class, BlindDateRoundConnectionSuccessDTO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long total(Date startTime, Date endDateTime) {
|
||||
return iBlindDateRoundConnectionSuccessService.countBlindDateRoundConnectionSuccess(startTime, endDateTime).longValue();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,29 @@
|
||||
package com.accompany.business.service.room.impl;
|
||||
|
||||
import com.accompany.business.service.room.MicCharmService;
|
||||
import com.accompany.common.redis.RedisKey;
|
||||
import com.accompany.core.service.common.JedisService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class MicCharmServiceImpl implements MicCharmService {
|
||||
|
||||
private JedisService jedisService;
|
||||
|
||||
@Autowired
|
||||
public void setJedisService(JedisService jedisService) {
|
||||
this.jedisService = jedisService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getByRoomUserIdAndUserId(Long roomUserId, Long userId) {
|
||||
String result = jedisService.hget(RedisKey.room_gift_value.getKey(roomUserId.toString()), userId.toString());
|
||||
if (result == null) {
|
||||
return null;
|
||||
}
|
||||
return Long.parseLong(result);
|
||||
}
|
||||
}
|
@@ -1,26 +0,0 @@
|
||||
package com.accompany.business.service.room.impl
|
||||
|
||||
import com.accompany.business.service.room.MicCharmService
|
||||
import com.accompany.common.redis.RedisKey
|
||||
import com.accompany.common.utils.JsonUtil
|
||||
import com.accompany.core.service.common.JedisService
|
||||
import org.springframework.beans.factory.annotation.Autowired
|
||||
import org.springframework.stereotype.Service
|
||||
import org.springframework.transaction.annotation.Transactional
|
||||
|
||||
@Service
|
||||
@Transactional(rollbackFor = [Exception::class])
|
||||
open class MicCharmServiceImpl : MicCharmService {
|
||||
|
||||
|
||||
@Autowired
|
||||
private lateinit var jedisService: JedisService
|
||||
|
||||
|
||||
override fun getByRoomUserIdAndUserId(roomUserId: Long, userId: Long): Long? {
|
||||
val result = jedisService.hget(RedisKey.room_gift_value.getKey(roomUserId.toString()), userId.toString())
|
||||
?: return null
|
||||
return result.toLong()
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,60 @@
|
||||
package com.accompany.business.service.room.impl;
|
||||
|
||||
import com.accompany.business.dto.SendRoomMsgDTO;
|
||||
import com.accompany.business.dto.SendRoomMsgTemplate;
|
||||
import com.accompany.business.service.room.PushRoomService;
|
||||
import com.accompany.business.util.NetEaseHttpUtil;
|
||||
import com.accompany.core.annotation.LogTime;
|
||||
import com.accompany.core.dto.HttpForm;
|
||||
import com.accompany.core.util.JsonUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.xml.ws.Response;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class PushRoomServiceImpl implements PushRoomService {
|
||||
|
||||
@Override
|
||||
public void sendRoomMsg(SendRoomMsgTemplate sendRoomMsgTemplate) {
|
||||
SendRoomMsgDTO sendRoomMsgDTO = new SendRoomMsgDTO();
|
||||
sendRoomMsgDTO.setRoomid(sendRoomMsgTemplate.getToRoomId());
|
||||
sendRoomMsgDTO.setFromAccid(String.valueOf(sendRoomMsgTemplate.getFromUserId()));
|
||||
sendRoomMsgDTO.setAttach(sendRoomMsgTemplate.getAttach());
|
||||
send(sendRoomMsgDTO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendRoomTextMsg(SendRoomMsgTemplate sendRoomMsgTemplate) {
|
||||
SendRoomMsgDTO sendRoomMsgDTO = new SendRoomMsgDTO();
|
||||
sendRoomMsgDTO.setMsgType(0);
|
||||
sendRoomMsgDTO.setRoomid(sendRoomMsgTemplate.getToRoomId());
|
||||
sendRoomMsgDTO.setFromAccid(String.valueOf(sendRoomMsgTemplate.getFromUserId()));
|
||||
sendRoomMsgDTO.setAttach(sendRoomMsgTemplate.getAttach());
|
||||
send(sendRoomMsgDTO);
|
||||
}
|
||||
|
||||
@LogTime
|
||||
@Override
|
||||
public void sendTip(SendRoomMsgTemplate sendRoomMsgTemplate) {
|
||||
SendRoomMsgDTO sendRoomMsgDTO = new SendRoomMsgDTO();
|
||||
sendRoomMsgDTO.setRoomid(sendRoomMsgTemplate.getToRoomId());
|
||||
sendRoomMsgDTO.setFromAccid(String.valueOf(sendRoomMsgTemplate.getFromUserId()));
|
||||
sendRoomMsgDTO.setAttach(sendRoomMsgTemplate.getAttach());
|
||||
sendRoomMsgDTO.setMsgType(10);
|
||||
send(sendRoomMsgDTO);
|
||||
}
|
||||
|
||||
private void send(SendRoomMsgDTO sendRoomMsgDTO) {
|
||||
Map<String, String> httpForms = JsonUtil.parseToClass(JsonUtil.parseToString(sendRoomMsgDTO), Map.class);
|
||||
log.info("发送房间消息 " + JsonUtil.parseToString(httpForms));
|
||||
String response = NetEaseHttpUtil.postWithForm("https://api.netease.im/nimserver/chatroom/sendMsg.action", httpForms);
|
||||
log.info("发送房间消息返回 " + JsonUtil.parseToString(response));
|
||||
}
|
||||
}
|
@@ -1,60 +0,0 @@
|
||||
package com.accompany.business.service.room.impl
|
||||
|
||||
import com.accompany.business.dto.SendRoomMsgDTO
|
||||
import com.accompany.business.dto.SendRoomMsgTemplate
|
||||
import com.accompany.business.service.room.PushRoomService
|
||||
import com.accompany.business.util.NetEaseHttpUtil
|
||||
import com.accompany.core.annotation.LogTime
|
||||
import com.accompany.core.dto.HttpForm
|
||||
import com.accompany.core.util.JsonUtil
|
||||
import org.slf4j.LoggerFactory
|
||||
import org.springframework.stereotype.Service
|
||||
import org.springframework.transaction.annotation.Transactional
|
||||
|
||||
@Service
|
||||
@Transactional(rollbackFor = [Exception::class])
|
||||
open class PushRoomServiceImpl : PushRoomService {
|
||||
|
||||
private val log = LoggerFactory.getLogger(PushRoomServiceImpl::class.java)
|
||||
|
||||
override fun sendRoomMsg(sendRoomMsgTemplate: SendRoomMsgTemplate) {
|
||||
val sendRoomMsgDTO = SendRoomMsgDTO()
|
||||
sendRoomMsgDTO.roomid = sendRoomMsgTemplate.toRoomId
|
||||
sendRoomMsgDTO.fromAccid = sendRoomMsgTemplate.fromUserId.toString()
|
||||
sendRoomMsgDTO.attach = sendRoomMsgTemplate.attach
|
||||
send(sendRoomMsgDTO)
|
||||
}
|
||||
|
||||
override fun sendRoomTextMsg(sendRoomMsgTemplate: SendRoomMsgTemplate) {
|
||||
val sendRoomMsgDTO = SendRoomMsgDTO()
|
||||
sendRoomMsgDTO.msgType = 0
|
||||
sendRoomMsgDTO.roomid = sendRoomMsgTemplate.toRoomId
|
||||
sendRoomMsgDTO.fromAccid = sendRoomMsgTemplate.fromUserId.toString()
|
||||
sendRoomMsgDTO.attach = sendRoomMsgTemplate.attach
|
||||
send(sendRoomMsgDTO)
|
||||
}
|
||||
|
||||
@LogTime
|
||||
override fun sendTip(sendRoomMsgTemplate: SendRoomMsgTemplate) {
|
||||
val sendRoomMsgDTO = SendRoomMsgDTO()
|
||||
sendRoomMsgDTO.roomid = sendRoomMsgTemplate.toRoomId
|
||||
sendRoomMsgDTO.fromAccid = sendRoomMsgTemplate.fromUserId.toString()
|
||||
sendRoomMsgDTO.attach = sendRoomMsgTemplate.attach
|
||||
sendRoomMsgDTO.msgType = 10
|
||||
send(sendRoomMsgDTO)
|
||||
}
|
||||
|
||||
private fun send(sendRoomMsgDTO: SendRoomMsgDTO) {
|
||||
val httpForms = JsonUtil.parseToClass(JsonUtil.parseToString(sendRoomMsgDTO), Map::class.java).map {
|
||||
val httpForm = HttpForm()
|
||||
httpForm.name = it.key.toString()
|
||||
httpForm.value = it.value.toString()
|
||||
httpForm
|
||||
}
|
||||
log.info("发送房间消息 ${JsonUtil.parseToString(httpForms)}")
|
||||
val response = NetEaseHttpUtil.postWithForm("https://api.netease.im/nimserver/chatroom/sendMsg.action", httpForms)!!
|
||||
log.info("发送房间消息返回 ${JsonUtil.parseToString(response)}")
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,53 @@
|
||||
package com.accompany.business.service.room.impl;
|
||||
|
||||
import com.accompany.business.dto.*;
|
||||
import com.accompany.business.service.room.QueryRoomService;
|
||||
import com.accompany.business.util.NetEaseHttpUtil;
|
||||
import com.accompany.core.util.JsonUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class QueryRoomServiceImpl implements QueryRoomService {
|
||||
|
||||
/**
|
||||
* 删除普通广播内容
|
||||
*/
|
||||
@Override
|
||||
public void deleteMsg(DeleteMessageDTO deleteMessageDTO) {
|
||||
Map<String, String> httpForms = JsonUtil.parseToClass(JsonUtil.parseToString(deleteMessageDTO), Map.class);
|
||||
log.info("删除房间信息请求 {}", JsonUtil.parseToString(httpForms));
|
||||
String response = NetEaseHttpUtil.postWithForm("https://api.netease.im/nimserver/chatroom/deleteHistoryMessage.action", httpForms);
|
||||
log.info("删除房间信息返回 {}", response);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOperation(SetOperationDTO dto) {
|
||||
Map<String, String> httpForms = JsonUtil.parseToClass(JsonUtil.parseToString(dto), Map.class);
|
||||
log.info("设置聊天室内用户角色请求 {}", JsonUtil.parseToString(httpForms));
|
||||
String response = NetEaseHttpUtil.postWithForm("https://api.netease.im/nimserver/chatroom/setMemberRole.action", httpForms);
|
||||
log.info("设置聊天室内用户角色返回 {}", response);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueueListResponseDTO queueList(Long roomId) {
|
||||
QueueListDTO queueListDTO = new QueueListDTO(roomId);
|
||||
Map<String, String> httpForms = JsonUtil.parseToClass(JsonUtil.parseToString(queueListDTO), Map.class);
|
||||
log.info("查询房间队列消息参数 {}", JsonUtil.parseToString(httpForms));
|
||||
String response = NetEaseHttpUtil.postWithForm("https://api.netease.im/nimserver/chatroom/queueList.action", httpForms);
|
||||
log.info("查询房间队列消息结果 {}", response);
|
||||
return JsonUtil.parseToClass(response, QueueListResponseDTO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryRoomStateResponseDTO state(QueryRoomStateDTO queryRoomStateDTO) {
|
||||
Map<String, String> httpForms = JsonUtil.parseToClass(JsonUtil.parseToString(queryRoomStateDTO), Map.class);
|
||||
log.info("查询房间信息请求 {}", JsonUtil.parseToString(httpForms));
|
||||
String response = NetEaseHttpUtil.postWithForm("https://api.netease.im/nimserver/chatroom/get.action", httpForms);
|
||||
log.info("查询房间信息返回 {}", response);
|
||||
return JsonUtil.parseToClass(response, QueryRoomStateResponseDTO.class);
|
||||
}
|
||||
}
|
@@ -1,74 +0,0 @@
|
||||
package com.accompany.business.service.room.impl
|
||||
|
||||
import com.accompany.business.dto.*
|
||||
import com.accompany.business.service.room.QueryRoomService
|
||||
import com.accompany.business.util.NetEaseHttpUtil
|
||||
import com.accompany.core.dto.HttpForm
|
||||
import com.accompany.core.util.JsonUtil
|
||||
import org.slf4j.LoggerFactory
|
||||
import org.springframework.stereotype.Service
|
||||
|
||||
@Service
|
||||
open class QueryRoomServiceImpl : QueryRoomService {
|
||||
|
||||
private val log = LoggerFactory.getLogger(QueryRoomServiceImpl::class.java)
|
||||
|
||||
|
||||
/**
|
||||
* 删除普通广播内容
|
||||
*/
|
||||
override fun deleteMsg(deleteMessageDTO: DeleteMessageDTO) {
|
||||
val httpForms = JsonUtil.parseToClass(JsonUtil.parseToString(deleteMessageDTO), Map::class.java).map {
|
||||
val httpForm = HttpForm()
|
||||
httpForm.name = it.key.toString()
|
||||
httpForm.value = it.value.toString()
|
||||
httpForm
|
||||
}
|
||||
log.info("删除房间信息请求 ${JsonUtil.parseToString(httpForms)}")
|
||||
val response = NetEaseHttpUtil.postWithForm("https://api.netease.im/nimserver/chatroom/deleteHistoryMessage.action", httpForms)!!
|
||||
log.info("删除房间信息返回 ${JsonUtil.parseToString(response)}")
|
||||
}
|
||||
|
||||
override fun setOperation(dto: SetOperationDTO) {
|
||||
val httpForms = JsonUtil.parseToClass(JsonUtil.parseToString(dto), Map::class.java).map {
|
||||
val httpForm = HttpForm()
|
||||
httpForm.name = it.key.toString()
|
||||
httpForm.value = it.value.toString()
|
||||
httpForm
|
||||
}
|
||||
log.info("设置聊天室内用户角色请求 ${JsonUtil.parseToString(httpForms)}")
|
||||
val response = NetEaseHttpUtil.postWithForm("https://api.netease.im/nimserver/chatroom/setMemberRole.action", httpForms)!!
|
||||
log.info("设置聊天室内用户角色返回 ${JsonUtil.parseToString(response)}")
|
||||
}
|
||||
|
||||
override fun queueList(roomId: Long): QueueListResponseDTO {
|
||||
val queueListDTO = QueueListDTO(roomId)
|
||||
val httpForms = JsonUtil.parseToClass(JsonUtil.parseToString(queueListDTO), Map::class.java).map {
|
||||
val httpForm = HttpForm()
|
||||
httpForm.name = it.key.toString()
|
||||
httpForm.value = it.value.toString()
|
||||
httpForm
|
||||
}
|
||||
log.info("查询房间队列消息参数 ${JsonUtil.parseToString(httpForms)}")
|
||||
val response = NetEaseHttpUtil.postWithForm("https://api.netease.im/nimserver/chatroom/queueList.action", httpForms)!!
|
||||
log.info("查询房间队列消息结果 ${JsonUtil.parseToString(response)}")
|
||||
return JsonUtil.parseToClass(response, QueueListResponseDTO::class.java)
|
||||
}
|
||||
|
||||
override fun state(queryRoomStateDTO: QueryRoomStateDTO): QueryRoomStateResponseDTO {
|
||||
val httpForms = JsonUtil.parseToClass(JsonUtil.parseToString(queryRoomStateDTO), Map::class.java).map {
|
||||
val httpForm = HttpForm()
|
||||
httpForm.name = it.key.toString()
|
||||
httpForm.value = it.value.toString()
|
||||
httpForm
|
||||
}
|
||||
log.info("查询房间信息请求 ${JsonUtil.parseToString(httpForms)}")
|
||||
val response = NetEaseHttpUtil.postWithForm("https://api.netease.im/nimserver/chatroom/get.action", httpForms)!!
|
||||
log.info("查询房间信息返回 ${JsonUtil.parseToString(response)}")
|
||||
return JsonUtil.parseToClass(response, QueryRoomStateResponseDTO::class.java)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,57 @@
|
||||
package com.accompany.business.service.room.impl;
|
||||
|
||||
import com.accompany.business.dto.QueueDTO;
|
||||
import com.accompany.business.dto.QueuePoolDTO;
|
||||
import com.accompany.business.service.room.QueryRoomService;
|
||||
import com.accompany.business.service.room.QueueService;
|
||||
import com.accompany.business.util.NetEaseHttpUtil;
|
||||
import com.accompany.core.annotation.Lock;
|
||||
import com.accompany.core.util.JsonUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public class QueueServiceImpl implements QueueService {
|
||||
|
||||
@Autowired
|
||||
private QueryRoomService queryRoomService;
|
||||
|
||||
@Lock("'QueueServiceImpl-upsert' + #dto.roomid ")
|
||||
@Override
|
||||
public void upsert(QueueDTO dto) {
|
||||
List<QueueDTO> queueList = queryRoomService.queueList(dto.getRoomid()).getDesc().listDTO();
|
||||
QueueDTO queueDTO = queueList.stream()
|
||||
.filter(q -> q.getValueObject().getPosition().equals(dto.getValueObject().getPosition()))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
if (queueDTO != null) {
|
||||
String old = queueDTO.getValue();
|
||||
String newValue = dto.getValue();
|
||||
log.info("old is {} and new is {}", old, newValue);
|
||||
if (old.equals(newValue)) {
|
||||
log.info("新旧元素一样,所以不更新了");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, String> httpForms = JsonUtil.parseToClass(JsonUtil.parseToString(dto), Map.class);
|
||||
log.info("新增或更新队列信息请求 {}", JsonUtil.parseToString(httpForms));
|
||||
String response = NetEaseHttpUtil.postWithForm("https://api.netease.im/nimserver/chatroom/queueOffer.action", httpForms);
|
||||
log.info("新增或更新队列信息响应 {}", response);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void queuePoll(QueuePoolDTO dto) {
|
||||
Map<String, String> httpForms = JsonUtil.parseToClass(JsonUtil.parseToString(dto), Map.class);
|
||||
log.info("弹出房间队列信息请求 {}", JsonUtil.parseToString(httpForms));
|
||||
String response = NetEaseHttpUtil.postWithForm("https://api.netease.im/nimserver/chatroom/queuePoll.action", httpForms);
|
||||
log.info("删除房间队列信息返回 {}", response);
|
||||
}
|
||||
}
|
@@ -1,64 +0,0 @@
|
||||
package com.accompany.business.service.room.impl
|
||||
|
||||
import com.accompany.business.dto.QueueDTO
|
||||
import com.accompany.business.dto.QueuePoolDTO
|
||||
import com.accompany.business.service.room.QueryRoomService
|
||||
import com.accompany.business.service.room.QueueService
|
||||
import com.accompany.business.util.NetEaseHttpUtil
|
||||
import com.accompany.core.annotation.Lock
|
||||
import com.accompany.core.dto.HttpForm
|
||||
import com.accompany.core.util.JsonUtil
|
||||
import org.slf4j.LoggerFactory
|
||||
import org.springframework.beans.factory.annotation.Autowired
|
||||
import org.springframework.stereotype.Service
|
||||
import org.springframework.transaction.annotation.Transactional
|
||||
|
||||
@Service
|
||||
@Transactional(rollbackFor = [Exception::class])
|
||||
open class QueueServiceImpl: QueueService {
|
||||
|
||||
private val log = LoggerFactory.getLogger(QueueServiceImpl::class.java)
|
||||
|
||||
@Autowired
|
||||
private lateinit var queryRoomService: QueryRoomService
|
||||
|
||||
@Lock("'QueueServiceImpl-upsert' + #dto.roomid ")
|
||||
override fun upsert(dto: QueueDTO) {
|
||||
val queueList = queryRoomService.queueList(dto.roomid)
|
||||
val queueDTO = queueList.desc
|
||||
.listDTO()
|
||||
.firstOrNull { it.valueObject.position == dto.valueObject.position }
|
||||
if (queueDTO != null) {
|
||||
val old = queueDTO.value
|
||||
val new = dto.value
|
||||
log.info("old is $old and new is $new")
|
||||
if (old == new) {
|
||||
log.info("新旧元素一样,所以不更新了")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
val httpForms = JsonUtil.parseToClass(JsonUtil.parseToString(dto), Map::class.java).map {
|
||||
val httpForm = HttpForm()
|
||||
httpForm.name = it.key.toString()
|
||||
httpForm.value = it.value.toString()
|
||||
httpForm
|
||||
}
|
||||
log.info("新增或更新队列信息请求 ${JsonUtil.parseToString(httpForms)}")
|
||||
val response = NetEaseHttpUtil.postWithForm("https://api.netease.im/nimserver/chatroom/queueOffer.action", httpForms)!!
|
||||
log.info("新增或更新队列信息响应 ${JsonUtil.parseToString(response)}")
|
||||
}
|
||||
|
||||
|
||||
override fun queuePoll(dto: QueuePoolDTO) {
|
||||
val httpForms = JsonUtil.parseToClass(JsonUtil.parseToString(dto), Map::class.java).map {
|
||||
val httpForm = HttpForm()
|
||||
httpForm.name = it.key.toString()
|
||||
httpForm.value = it.value.toString()
|
||||
httpForm
|
||||
}
|
||||
log.info("弹出房间队列信息请求 ${JsonUtil.parseToString(httpForms)}")
|
||||
val response = NetEaseHttpUtil.postWithForm("https://api.netease.im/nimserver/chatroom/queuePoll.action", httpForms)!!
|
||||
log.info("删除房间队列信息返回 ${JsonUtil.parseToString(response)}")
|
||||
}
|
||||
}
|
@@ -0,0 +1,44 @@
|
||||
package com.accompany.business.util;
|
||||
|
||||
import com.accompany.common.config.NetEaseConfig;
|
||||
import com.accompany.common.netease.util.CheckSumBuilder;
|
||||
import com.accompany.common.utils.RandomUtil;
|
||||
import com.accompany.core.dto.HttpForm;
|
||||
import com.accompany.core.dto.HttpHeader;
|
||||
import com.accompany.core.util.OkHttpUtils;
|
||||
import com.google.common.collect.Lists;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 云信 http 工具
|
||||
*/
|
||||
public class NetEaseHttpUtil {
|
||||
|
||||
public static String postWithForm(String p2pSendUrl, Map<String, String> httpFormMap) {
|
||||
List<HttpForm> httpForms = new ArrayList<>();
|
||||
|
||||
httpFormMap.forEach((key, value) -> {
|
||||
HttpForm httpForm = new HttpForm();
|
||||
httpForm.setName(key);
|
||||
httpForm.setValue(value);
|
||||
httpForms.add(httpForm);
|
||||
});
|
||||
|
||||
return postWithForm(p2pSendUrl, httpForms);
|
||||
}
|
||||
|
||||
public static String postWithForm(String p2pSendUrl, List<HttpForm> httpForm) {
|
||||
ArrayList<HttpHeader> httpFormHeaders = Lists.newArrayList();
|
||||
String appKey = NetEaseConfig.neteaseAppKey;
|
||||
String neteaseAppSecret = NetEaseConfig.neteaseAppSecret;
|
||||
String randomNumStringOfLength = RandomUtil.getFiveRandomNumber() + "";
|
||||
String value = System.currentTimeMillis() / 1000 + "";
|
||||
|
||||
httpFormHeaders.add(new HttpHeader("AppKey", appKey));
|
||||
httpFormHeaders.add(new HttpHeader("Nonce", randomNumStringOfLength));
|
||||
httpFormHeaders.add(new HttpHeader("CurTime", value));
|
||||
httpFormHeaders.add(new HttpHeader("CheckSum", CheckSumBuilder.getCheckSum(neteaseAppSecret, randomNumStringOfLength, value)));
|
||||
return OkHttpUtils.postWithFormWithHeader(httpFormHeaders, p2pSendUrl, httpForm);
|
||||
}
|
||||
|
||||
}
|
@@ -1,38 +0,0 @@
|
||||
package com.accompany.business.util
|
||||
|
||||
import com.accompany.common.config.NetEaseConfig
|
||||
import com.accompany.common.netease.util.CheckSumBuilder
|
||||
import com.accompany.common.utils.HttpUtils
|
||||
import com.accompany.common.utils.RandomUtil
|
||||
import com.accompany.core.dto.HttpForm
|
||||
import com.accompany.core.dto.HttpHeader
|
||||
import com.accompany.core.util.OkHttpUtils
|
||||
import com.google.common.collect.Lists
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
* 云信 http 工具
|
||||
*/
|
||||
class NetEaseHttpUtil {
|
||||
|
||||
companion object {
|
||||
|
||||
@JvmStatic
|
||||
fun postWithForm(p2pSendUrl: String, httpForm: List<HttpForm>): String? {
|
||||
val httpFormHeaders: ArrayList<HttpHeader> = Lists.newArrayList()
|
||||
val appKey = NetEaseConfig.neteaseAppKey
|
||||
val neteaseAppSecret = NetEaseConfig.neteaseAppSecret
|
||||
val randomNumStringOfLength = RandomUtil.getFiveRandomNumber().toString()
|
||||
val value = System.currentTimeMillis().div(1000).toString()
|
||||
|
||||
httpFormHeaders.add(HttpHeader("AppKey", appKey))
|
||||
httpFormHeaders.add(HttpHeader("Nonce", randomNumStringOfLength))
|
||||
httpFormHeaders.add(HttpHeader("CurTime", value))
|
||||
httpFormHeaders.add(HttpHeader("CheckSum", CheckSumBuilder.getCheckSum(neteaseAppSecret, randomNumStringOfLength, value)))
|
||||
return OkHttpUtils.postWithFormWithHeader(httpFormHeaders, p2pSendUrl, httpForm)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -75,8 +75,6 @@
|
||||
<jackson-datatype-joda.version>2.1.1</jackson-datatype-joda.version>
|
||||
<joda-time.version>2.10.5</joda-time.version>
|
||||
<mybatisplus.version>3.1.2</mybatisplus.version>
|
||||
<kotlin.version>1.4.0</kotlin.version>
|
||||
<jackson-module-kotlin.version>2.9.7</jackson-module-kotlin.version>
|
||||
<sud-mgp-auth-java.version>1.0.4</sud-mgp-auth-java.version>
|
||||
<redisson.version>3.16.8</redisson.version>
|
||||
<kotlin.compiler.incremental>true</kotlin.compiler.incremental>
|
||||
@@ -502,24 +500,6 @@
|
||||
<version>${joda-time.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-reflect</artifactId>
|
||||
<version>${kotlin.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-stdlib-jdk8</artifactId>
|
||||
<version>${kotlin.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.module</groupId>
|
||||
<artifactId>jackson-module-kotlin</artifactId>
|
||||
<version>${jackson-module-kotlin.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-core</artifactId>
|
||||
|
13
pom.xml
13
pom.xml
@@ -40,19 +40,6 @@
|
||||
<maxmem>1024m</maxmem>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>compile</id>
|
||||
<phase>compile</phase>
|
||||
<goals>
|
||||
<goal>compile</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
Reference in New Issue
Block a user