first commit
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
package com.lld.im.common;
|
||||
|
||||
|
||||
import com.lld.im.common.exception.ApplicationExceptionEnum;
|
||||
|
||||
|
||||
public enum BaseErrorCode implements ApplicationExceptionEnum {
|
||||
|
||||
SUCCESS(200,"success"),
|
||||
SYSTEM_ERROR(90000,"服务器内部错误,请联系管理员"),
|
||||
PARAMETER_ERROR(90001,"参数校验错误"),
|
||||
|
||||
|
||||
;
|
||||
|
||||
private int code;
|
||||
private String error;
|
||||
|
||||
BaseErrorCode(int code, String error){
|
||||
this.code = code;
|
||||
this.error = error;
|
||||
}
|
||||
public int getCode() {
|
||||
return this.code;
|
||||
}
|
||||
|
||||
public String getError() {
|
||||
return this.error;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.lld.im.common;
|
||||
|
||||
/**
|
||||
* @author: Chackylee
|
||||
* @description:
|
||||
**/
|
||||
public enum ClientType {
|
||||
|
||||
WEBAPI(0,"webApi"),
|
||||
WEB(1,"web"),
|
||||
IOS(2,"ios"),
|
||||
ANDROID(3,"android"),
|
||||
WINDOWS(4,"windows"),
|
||||
MAC(5,"mac"),
|
||||
;
|
||||
|
||||
private int code;
|
||||
private String error;
|
||||
|
||||
ClientType(int code, String error){
|
||||
this.code = code;
|
||||
this.error = error;
|
||||
}
|
||||
public int getCode() {
|
||||
return this.code;
|
||||
}
|
||||
|
||||
public String getError() {
|
||||
return this.error;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.lld.im.common;
|
||||
|
||||
import com.lld.im.common.exception.ApplicationExceptionEnum;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ResponseVO<T> {
|
||||
|
||||
private int code;
|
||||
|
||||
private String msg;
|
||||
|
||||
private T data;
|
||||
|
||||
public static ResponseVO successResponse(Object data) {
|
||||
return new ResponseVO(200, "success", data);
|
||||
}
|
||||
|
||||
public static ResponseVO successResponse() {
|
||||
return new ResponseVO(200, "success");
|
||||
}
|
||||
|
||||
public static ResponseVO errorResponse() {
|
||||
return new ResponseVO(500, "系统内部异常");
|
||||
}
|
||||
|
||||
public static ResponseVO errorResponse(int code, String msg) {
|
||||
return new ResponseVO(code, msg);
|
||||
}
|
||||
|
||||
public static ResponseVO errorResponse(ApplicationExceptionEnum enums) {
|
||||
return new ResponseVO(enums.getCode(), enums.getError());
|
||||
}
|
||||
|
||||
public boolean isOk(){
|
||||
return this.code == 200;
|
||||
}
|
||||
|
||||
|
||||
public ResponseVO(int code, String msg) {
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
// this.data = null;
|
||||
}
|
||||
|
||||
public ResponseVO success(){
|
||||
this.code = 200;
|
||||
this.msg = "success";
|
||||
return this;
|
||||
}
|
||||
|
||||
public ResponseVO success(T data){
|
||||
this.code = 200;
|
||||
this.msg = "success";
|
||||
this.data = data;
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.lld.im.common.enums;
|
||||
|
||||
public enum AllowFriendTypeEnum {
|
||||
|
||||
/**
|
||||
* 验证
|
||||
*/
|
||||
NEED(2),
|
||||
|
||||
/**
|
||||
* 不需要验证
|
||||
*/
|
||||
NOT_NEED(1),
|
||||
|
||||
;
|
||||
|
||||
|
||||
private int code;
|
||||
|
||||
AllowFriendTypeEnum(int code){
|
||||
this.code=code;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.lld.im.common.enums;
|
||||
|
||||
public enum ApproverFriendRequestStatusEnum {
|
||||
|
||||
/**
|
||||
* 1 同意;2 拒绝。
|
||||
*/
|
||||
AGREE(1),
|
||||
|
||||
REJECT(2),
|
||||
;
|
||||
|
||||
private int code;
|
||||
|
||||
ApproverFriendRequestStatusEnum(int code){
|
||||
this.code=code;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.lld.im.common.enums;
|
||||
|
||||
public enum CheckFriendShipTypeEnum {
|
||||
|
||||
/**
|
||||
* 1 单方校验;2双方校验。
|
||||
*/
|
||||
SINGLE(1),
|
||||
|
||||
BOTH(2),
|
||||
;
|
||||
|
||||
private int type;
|
||||
|
||||
CheckFriendShipTypeEnum(int type){
|
||||
this.type=type;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.lld.im.common.enums;
|
||||
|
||||
public enum DelFlagEnum {
|
||||
|
||||
/**
|
||||
* 0 正常;1 删除。
|
||||
*/
|
||||
NORMAL(0),
|
||||
|
||||
DELETE(1),
|
||||
;
|
||||
|
||||
private int code;
|
||||
|
||||
DelFlagEnum(int code){
|
||||
this.code=code;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.lld.im.common.enums;
|
||||
|
||||
import com.lld.im.common.exception.ApplicationExceptionEnum;
|
||||
|
||||
public enum FriendShipErrorCode implements ApplicationExceptionEnum {
|
||||
|
||||
|
||||
IMPORT_SIZE_BEYOND(30000,"导入數量超出上限"),
|
||||
|
||||
ADD_FRIEND_ERROR(30001,"添加好友失败"),
|
||||
|
||||
TO_IS_YOUR_FRIEND(30002,"对方已经是你的好友"),
|
||||
|
||||
TO_IS_NOT_YOUR_FRIEND(30003,"对方不是你的好友"),
|
||||
|
||||
FRIEND_IS_DELETED(30004,"好友已被删除"),
|
||||
|
||||
FRIEND_IS_BLACK(30006,"好友已被拉黑"),
|
||||
|
||||
TARGET_IS_BLACK_YOU(30007,"对方把你拉黑"),
|
||||
|
||||
REPEATSHIP_IS_NOT_EXIST(30008,"关系链记录不存在"),
|
||||
|
||||
ADD_BLACK_ERROR(30009,"添加黑名單失败"),
|
||||
|
||||
FRIEND_IS_NOT_YOUR_BLACK(30010,"好友已經不在你的黑名單内"),
|
||||
|
||||
NOT_APPROVER_OTHER_MAN_REQUEST(30011,"无法审批其他人的好友请求"),
|
||||
|
||||
FRIEND_REQUEST_IS_NOT_EXIST(30012,"好友申请不存在"),
|
||||
|
||||
FRIEND_SHIP_GROUP_CREATE_ERROR(30014,"好友分组创建失败"),
|
||||
|
||||
FRIEND_SHIP_GROUP_IS_EXIST(30015,"好友分组已存在"),
|
||||
|
||||
FRIEND_SHIP_GROUP_IS_NOT_EXIST(30016,"好友分组不存在"),
|
||||
|
||||
|
||||
|
||||
;
|
||||
|
||||
private int code;
|
||||
private String error;
|
||||
|
||||
FriendShipErrorCode(int code, String error){
|
||||
this.code = code;
|
||||
this.error = error;
|
||||
}
|
||||
public int getCode() {
|
||||
return this.code;
|
||||
}
|
||||
|
||||
public String getError() {
|
||||
return this.error;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.lld.im.common.enums;
|
||||
|
||||
public enum FriendShipStatusEnum {
|
||||
|
||||
/**
|
||||
* 0未添加 1正常 2删除
|
||||
*/
|
||||
FRIEND_STATUS_NO_FRIEND(0),
|
||||
|
||||
FRIEND_STATUS_NORMAL(1),
|
||||
|
||||
FRIEND_STATUS_DELETE(2),
|
||||
|
||||
/**
|
||||
* 0未添加 1正常 2删除
|
||||
*/
|
||||
BLACK_STATUS_NORMAL(1),
|
||||
|
||||
BLACK_STATUS_BLACKED(2),
|
||||
;
|
||||
|
||||
private int code;
|
||||
|
||||
FriendShipStatusEnum(int code){
|
||||
this.code=code;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.lld.im.common.enums;
|
||||
|
||||
import com.lld.im.common.exception.ApplicationExceptionEnum;
|
||||
|
||||
/**
|
||||
* @author: Chackylee
|
||||
* @description:
|
||||
**/
|
||||
public enum GroupErrorCode implements ApplicationExceptionEnum {
|
||||
|
||||
GROUP_IS_NOT_EXIST(40000,"群不存在"),
|
||||
|
||||
GROUP_IS_EXIST(40001,"群已存在"),
|
||||
|
||||
GROUP_IS_HAVE_OWNER(40002,"群已存在群主"),
|
||||
|
||||
USER_IS_JOINED_GROUP(40003,"该用户已经进入该群"),
|
||||
|
||||
USER_JOIN_GROUP_ERROR(40004,"群成员添加失败"),
|
||||
|
||||
GROUP_MEMBER_IS_BEYOND(40005,"群成员已达到上限"),
|
||||
|
||||
MEMBER_IS_NOT_JOINED_GROUP(40006,"该用户不在群内"),
|
||||
|
||||
THIS_OPERATE_NEED_MANAGER_ROLE(40007,"该操作只允许群主/管理员操作"),
|
||||
|
||||
THIS_OPERATE_NEED_APPMANAGER_ROLE(40008,"该操作只允许APP管理员操作"),
|
||||
|
||||
THIS_OPERATE_NEED_OWNER_ROLE(40009,"该操作只允许群主操作"),
|
||||
|
||||
GROUP_OWNER_IS_NOT_REMOVE(40010,"群主无法移除"),
|
||||
|
||||
UPDATE_GROUP_BASE_INFO_ERROR(40011,"更新群信息失败"),
|
||||
|
||||
THIS_GROUP_IS_MUTE(40012,"该群禁止发言"),
|
||||
|
||||
IMPORT_GROUP_ERROR(40013,"导入群组失败"),
|
||||
|
||||
THIS_OPERATE_NEED_ONESELF(40014,"该操作只允许自己操作"),
|
||||
|
||||
PRIVATE_GROUP_CAN_NOT_DESTORY(40015,"私有群不允许解散"),
|
||||
|
||||
PUBLIC_GROUP_MUST_HAVE_OWNER(40016,"公开群必须指定群主"),
|
||||
|
||||
GROUP_MEMBER_IS_SPEAK(40017,"群成员被禁言"),
|
||||
|
||||
GROUP_IS_DESTROY(40018,"群组已解散"),
|
||||
|
||||
;
|
||||
|
||||
private int code;
|
||||
private String error;
|
||||
|
||||
GroupErrorCode(int code, String error){
|
||||
this.code = code;
|
||||
this.error = error;
|
||||
}
|
||||
public int getCode() {
|
||||
return this.code;
|
||||
}
|
||||
|
||||
public String getError() {
|
||||
return this.error;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.lld.im.common.enums;
|
||||
|
||||
public enum GroupMemberRoleEnum {
|
||||
|
||||
/**
|
||||
* 普通成员
|
||||
*/
|
||||
ORDINARY(0),
|
||||
|
||||
/**
|
||||
* 管理员
|
||||
*/
|
||||
MAMAGER(1),
|
||||
|
||||
/**
|
||||
* 群主
|
||||
*/
|
||||
OWNER(2),
|
||||
|
||||
/**
|
||||
* 离开
|
||||
*/
|
||||
LEAVE(3);
|
||||
;
|
||||
|
||||
|
||||
private int code;
|
||||
|
||||
/**
|
||||
* 不能用 默认的 enumType b= enumType.values()[i]; 因为本枚举是类形式封装
|
||||
* @param ordinal
|
||||
* @return
|
||||
*/
|
||||
public static GroupMemberRoleEnum getItem(int ordinal) {
|
||||
for (int i = 0; i < GroupMemberRoleEnum.values().length; i++) {
|
||||
if (GroupMemberRoleEnum.values()[i].getCode() == ordinal) {
|
||||
return GroupMemberRoleEnum.values()[i];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
GroupMemberRoleEnum(int code){
|
||||
this.code=code;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.lld.im.common.enums;
|
||||
|
||||
public enum GroupMuteTypeEnum {
|
||||
|
||||
/**
|
||||
* 是否全员禁言,0 不禁言;1 全员禁言。
|
||||
*/
|
||||
NOT_MUTE(0),
|
||||
|
||||
|
||||
MUTE(1),
|
||||
|
||||
;
|
||||
|
||||
/**
|
||||
* 不能用 默认的 enumType b= enumType.values()[i]; 因为本枚举是类形式封装
|
||||
* @param ordinal
|
||||
* @return
|
||||
*/
|
||||
public static GroupMuteTypeEnum getEnum(Integer ordinal) {
|
||||
|
||||
if(ordinal == null){
|
||||
return null;
|
||||
}
|
||||
|
||||
for (int i = 0; i < GroupMuteTypeEnum.values().length; i++) {
|
||||
if (GroupMuteTypeEnum.values()[i].getCode() == ordinal) {
|
||||
return GroupMuteTypeEnum.values()[i];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private int code;
|
||||
|
||||
GroupMuteTypeEnum(int code){
|
||||
this.code=code;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.lld.im.common.enums;
|
||||
|
||||
public enum GroupStatusEnum {
|
||||
|
||||
/**
|
||||
* 1正常 2解散 其他待定比如封禁...
|
||||
*/
|
||||
NORMAL(1),
|
||||
|
||||
DESTROY(2),
|
||||
|
||||
;
|
||||
|
||||
/**
|
||||
* 不能用 默认的 enumType b= enumType.values()[i]; 因为本枚举是类形式封装
|
||||
* @param ordinal
|
||||
* @return
|
||||
*/
|
||||
public static GroupStatusEnum getEnum(Integer ordinal) {
|
||||
|
||||
if(ordinal == null){
|
||||
return null;
|
||||
}
|
||||
|
||||
for (int i = 0; i < GroupStatusEnum.values().length; i++) {
|
||||
if (GroupStatusEnum.values()[i].getCode() == ordinal) {
|
||||
return GroupStatusEnum.values()[i];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private int code;
|
||||
|
||||
GroupStatusEnum(int code){
|
||||
this.code=code;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.lld.im.common.enums;
|
||||
|
||||
public enum GroupTypeEnum {
|
||||
|
||||
/**
|
||||
* 群类型 1私有群(类似微信) 2公开群(类似qq)
|
||||
*/
|
||||
PRIVATE(1),
|
||||
|
||||
PUBLIC(2),
|
||||
|
||||
;
|
||||
|
||||
/**
|
||||
* 不能用 默认的 enumType b= enumType.values()[i]; 因为本枚举是类形式封装
|
||||
* @param ordinal
|
||||
* @return
|
||||
*/
|
||||
public static GroupTypeEnum getEnum(Integer ordinal) {
|
||||
|
||||
if(ordinal == null){
|
||||
return null;
|
||||
}
|
||||
|
||||
for (int i = 0; i < GroupTypeEnum.values().length; i++) {
|
||||
if (GroupTypeEnum.values()[i].getCode() == ordinal) {
|
||||
return GroupTypeEnum.values()[i];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private int code;
|
||||
|
||||
GroupTypeEnum(int code){
|
||||
this.code=code;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.lld.im.common.enums;
|
||||
|
||||
import com.lld.im.common.exception.ApplicationExceptionEnum;
|
||||
|
||||
public enum UserErrorCode implements ApplicationExceptionEnum {
|
||||
|
||||
|
||||
IMPORT_SIZE_BEYOND(20000,"导入數量超出上限"),
|
||||
USER_IS_NOT_EXIST(20001,"用户不存在"),
|
||||
SERVER_GET_USER_ERROR(20002,"服务获取用户失败"),
|
||||
MODIFY_USER_ERROR(20003,"更新用户失败"),
|
||||
SERVER_NOT_AVAILABLE(71000, "没有可用的服务"),
|
||||
;
|
||||
|
||||
private int code;
|
||||
private String error;
|
||||
|
||||
UserErrorCode(int code, String error){
|
||||
this.code = code;
|
||||
this.error = error;
|
||||
}
|
||||
public int getCode() {
|
||||
return this.code;
|
||||
}
|
||||
|
||||
public String getError() {
|
||||
return this.error;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.lld.im.common.enums;
|
||||
|
||||
public enum UserForbiddenFlagEnum {
|
||||
|
||||
/**
|
||||
* 0 正常;1 禁用。
|
||||
*/
|
||||
NORMAL(0),
|
||||
|
||||
FORBIBBEN(1),
|
||||
;
|
||||
|
||||
private int code;
|
||||
|
||||
UserForbiddenFlagEnum(int code){
|
||||
this.code=code;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.lld.im.common.enums;
|
||||
|
||||
public enum UserSilentFlagEnum {
|
||||
|
||||
/**
|
||||
* 0 正常;1 禁言。
|
||||
*/
|
||||
NORMAL(0),
|
||||
|
||||
MUTE(1),
|
||||
;
|
||||
|
||||
private int code;
|
||||
|
||||
UserSilentFlagEnum(int code){
|
||||
this.code=code;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.lld.im.common.exception;
|
||||
|
||||
/**
|
||||
* @author: Chackylee
|
||||
* @description:
|
||||
**/
|
||||
public class ApplicationException extends RuntimeException {
|
||||
|
||||
private int code;
|
||||
|
||||
private String error;
|
||||
|
||||
|
||||
public ApplicationException(int code, String message) {
|
||||
super(message);
|
||||
this.code = code;
|
||||
this.error = message;
|
||||
}
|
||||
|
||||
public ApplicationException(ApplicationExceptionEnum exceptionEnum) {
|
||||
super(exceptionEnum.getError());
|
||||
this.code = exceptionEnum.getCode();
|
||||
this.error = exceptionEnum.getError();
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getError() {
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* avoid the expensive and useless stack trace for api exceptions
|
||||
* @see Throwable#fillInStackTrace()
|
||||
*/
|
||||
@Override
|
||||
public Throwable fillInStackTrace() {
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.lld.im.common.exception;
|
||||
|
||||
public interface ApplicationExceptionEnum {
|
||||
|
||||
int getCode();
|
||||
|
||||
String getError();
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.lld.im.common.model;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author: Chackylee
|
||||
* @description:
|
||||
**/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class ClientInfo {
|
||||
|
||||
private Integer appId;
|
||||
|
||||
private Integer clientType;
|
||||
|
||||
private String imei;
|
||||
|
||||
public ClientInfo(Integer appId, Integer clientType, String imei) {
|
||||
this.appId = appId;
|
||||
this.clientType = clientType;
|
||||
this.imei = imei;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.lld.im.common.model;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @description:
|
||||
* @author: lld
|
||||
* @version: 1.0
|
||||
*/
|
||||
@Data
|
||||
public class RequestBase {
|
||||
private Integer appId;
|
||||
|
||||
private String operater;
|
||||
|
||||
private Integer clientType;
|
||||
|
||||
private String imei;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.lld.im.common.model;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @description:
|
||||
* @author: lld
|
||||
* @version: 1.0
|
||||
*/
|
||||
@Data
|
||||
public class UserClientDto {
|
||||
|
||||
private Integer appId;
|
||||
|
||||
private Integer clientType;
|
||||
|
||||
private String userId;
|
||||
|
||||
private String imei;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.lld.im.common.model;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @description:
|
||||
* @author: lld
|
||||
* @version: 1.0
|
||||
*/
|
||||
@Data
|
||||
public class UserSession {
|
||||
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
* 应用ID
|
||||
*/
|
||||
private Integer appId;
|
||||
|
||||
/**
|
||||
* 端的标识
|
||||
*/
|
||||
private Integer clientType;
|
||||
|
||||
//sdk 版本号
|
||||
private Integer version;
|
||||
|
||||
//连接状态 1=在线 2=离线
|
||||
private Integer connectState;
|
||||
|
||||
private Integer brokerId;
|
||||
|
||||
private String brokerHost;
|
||||
|
||||
private String imei;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user