first commit
This commit is contained in:
7
.gitignore
vendored
Normal file
7
.gitignore
vendored
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
**/.idea
|
||||||
|
/logs
|
||||||
|
**/im-service/target
|
||||||
|
**/im-codec/target
|
||||||
|
**/im-common/target
|
||||||
|
**/im-message-store/target
|
||||||
|
**/im-tcp/target
|
||||||
2
app-sqlite-master/app-sqlite/.gitignore
vendored
Normal file
2
app-sqlite-master/app-sqlite/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
/unpackage
|
||||||
|
/.hbuilderx
|
||||||
36
app-sqlite-master/app-sqlite/App.vue
Normal file
36
app-sqlite-master/app-sqlite/App.vue
Normal file
File diff suppressed because one or more lines are too long
0
app-sqlite-master/app-sqlite/README.md
Normal file
0
app-sqlite-master/app-sqlite/README.md
Normal file
33
app-sqlite-master/app-sqlite/common/common.css
Normal file
33
app-sqlite-master/app-sqlite/common/common.css
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
/* 1. 页面背景色 */
|
||||||
|
.page{
|
||||||
|
background-color: #EDEDED;
|
||||||
|
/* #ifndef APP-PLUS-NVUE */
|
||||||
|
min-height: 100vh;
|
||||||
|
height: auto;
|
||||||
|
/* #endif */
|
||||||
|
/* #ifdef APP-PLUS-NVUE */
|
||||||
|
flex: 1;
|
||||||
|
/* #endif */
|
||||||
|
}
|
||||||
|
/* 2. 主背景色(原谅绿) */
|
||||||
|
.main-bg-color{
|
||||||
|
background-color: #08C060;
|
||||||
|
}
|
||||||
|
.main-bg-hover-color{
|
||||||
|
background-color: #08d869;
|
||||||
|
}
|
||||||
|
/* 3. 主文字色(原谅绿) */
|
||||||
|
.main-text-color{
|
||||||
|
color: #08C060;
|
||||||
|
}
|
||||||
|
|
||||||
|
.border-main{
|
||||||
|
border-color: #08C060!important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bg-chat-item{
|
||||||
|
background-color: #6BEE68;
|
||||||
|
}
|
||||||
|
.text-chat-item{
|
||||||
|
color: #6BEE68;
|
||||||
|
}
|
||||||
11
app-sqlite-master/app-sqlite/common/icon.css
Normal file
11
app-sqlite-master/app-sqlite/common/icon.css
Normal file
File diff suppressed because one or more lines are too long
14
app-sqlite-master/app-sqlite/common/lib/config.js
Normal file
14
app-sqlite-master/app-sqlite/common/lib/config.js
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
export default {
|
||||||
|
// #ifndef H5
|
||||||
|
baseUrl:"http://192.168.100.12:8000",
|
||||||
|
// #endif
|
||||||
|
|
||||||
|
// #ifdef H5
|
||||||
|
baseUrl:"http://192.168.100.12:8000",
|
||||||
|
// #endif
|
||||||
|
|
||||||
|
version: "/v1",
|
||||||
|
|
||||||
|
env:"dev",
|
||||||
|
appId: 10000
|
||||||
|
}
|
||||||
95
app-sqlite-master/app-sqlite/common/lib/request.js
Normal file
95
app-sqlite-master/app-sqlite/common/lib/request.js
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
import $C from './config.js';
|
||||||
|
import $U from './util.js';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
// 全局配置
|
||||||
|
common:{
|
||||||
|
baseUrl:$C.baseUrl + $C.version,
|
||||||
|
header:{
|
||||||
|
'Content-Type':'application/json;charset=UTF-8',
|
||||||
|
},
|
||||||
|
data:{},
|
||||||
|
method:'GET',
|
||||||
|
dataType:'json',
|
||||||
|
token:true,
|
||||||
|
},
|
||||||
|
// 请求 返回promise
|
||||||
|
request(options = {}){
|
||||||
|
// 组织参数
|
||||||
|
options.url = this.common.baseUrl + options.url
|
||||||
|
options.header = options.header || this.common.header
|
||||||
|
options.data = options.data || this.common.data
|
||||||
|
options.method = options.method || this.common.method
|
||||||
|
options.dataType = options.dataType || this.common.dataType
|
||||||
|
options.token = options.token === false ? false : this.common.token
|
||||||
|
// params
|
||||||
|
options.url = options.url + "?appId=10000"
|
||||||
|
console.log(options.url)
|
||||||
|
|
||||||
|
// 请求
|
||||||
|
return new Promise((res,rej)=>{
|
||||||
|
// 请求中...
|
||||||
|
uni.request({
|
||||||
|
...options,
|
||||||
|
success: (result) => {
|
||||||
|
// 返回原始数据
|
||||||
|
if(options.native){
|
||||||
|
return res(result)
|
||||||
|
}
|
||||||
|
console.log(result.statusCode)
|
||||||
|
// 服务端失败
|
||||||
|
if(result.statusCode !== 200){
|
||||||
|
if (options.toast !== false) {
|
||||||
|
uni.showToast({
|
||||||
|
title: result.data.data || '服务端失败',
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return rej(result.data)
|
||||||
|
}
|
||||||
|
// 其他验证...
|
||||||
|
// 成功
|
||||||
|
let data = result.data
|
||||||
|
|
||||||
|
res(data)
|
||||||
|
},
|
||||||
|
fail: (error) => {
|
||||||
|
uni.showToast({ title: error.errMsg || '请求失败', icon: 'none' });
|
||||||
|
return rej(error)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})
|
||||||
|
},
|
||||||
|
setQueryConfig(params){
|
||||||
|
var _str = "?";
|
||||||
|
for(var o in params){
|
||||||
|
if(params[o] != -1){
|
||||||
|
_str += o + "=" + params[o] + "&";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var _str = _str.substring(0, _str.length-1); //末尾是&
|
||||||
|
return _str;
|
||||||
|
},
|
||||||
|
// get请求
|
||||||
|
get(url,data = {},options = {}){
|
||||||
|
options.url = url
|
||||||
|
options.data = data
|
||||||
|
options.method = 'GET'
|
||||||
|
return this.request(options)
|
||||||
|
},
|
||||||
|
// post请求
|
||||||
|
post(url,data = {},options = {}){
|
||||||
|
options.url = url
|
||||||
|
options.data = data
|
||||||
|
options.method = 'POST'
|
||||||
|
console.log(options)
|
||||||
|
return this.request(options)
|
||||||
|
},
|
||||||
|
// delete请求
|
||||||
|
del(url,data = {},options = {}){
|
||||||
|
options.url = url
|
||||||
|
options.data = data
|
||||||
|
options.method = 'DELETE'
|
||||||
|
return this.request(options)
|
||||||
|
}
|
||||||
|
}
|
||||||
44
app-sqlite-master/app-sqlite/common/lib/util.js
Normal file
44
app-sqlite-master/app-sqlite/common/lib/util.js
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
import $C from './config.js'
|
||||||
|
export default {
|
||||||
|
// 获取存储列表数据
|
||||||
|
getStorage(key){
|
||||||
|
let data = null;
|
||||||
|
// #ifdef H5
|
||||||
|
if($C.env === 'dev'){
|
||||||
|
data = window.sessionStorage.getItem(key)
|
||||||
|
} else {
|
||||||
|
data = uni.getStorageSync(key)
|
||||||
|
}
|
||||||
|
// #endif
|
||||||
|
// #ifndef H5
|
||||||
|
data = uni.getStorageSync(key)
|
||||||
|
// #endif
|
||||||
|
return data
|
||||||
|
},
|
||||||
|
// 设置存储
|
||||||
|
setStorage(key,data){
|
||||||
|
// #ifdef H5
|
||||||
|
if($C.env === 'dev'){
|
||||||
|
return window.sessionStorage.setItem(key,data)
|
||||||
|
} else {
|
||||||
|
return uni.setStorageSync(key,data)
|
||||||
|
}
|
||||||
|
// #endif
|
||||||
|
// #ifndef H5
|
||||||
|
return uni.setStorageSync(key,data)
|
||||||
|
// #endif
|
||||||
|
},
|
||||||
|
// 删除存储
|
||||||
|
removeStorage(key){
|
||||||
|
// #ifdef H5
|
||||||
|
if($C.env === 'dev'){
|
||||||
|
return window.sessionStorage.removeItem(key);
|
||||||
|
} else {
|
||||||
|
return uni.removeStorageSync(key)
|
||||||
|
}
|
||||||
|
// #endif
|
||||||
|
// #ifndef H5
|
||||||
|
return uni.removeStorageSync(key)
|
||||||
|
// #endif
|
||||||
|
}
|
||||||
|
}
|
||||||
399
app-sqlite-master/app-sqlite/common/my.css
Normal file
399
app-sqlite-master/app-sqlite/common/my.css
Normal file
@@ -0,0 +1,399 @@
|
|||||||
|
/* 图标 */
|
||||||
|
.iconfont{
|
||||||
|
font-family:iconfont;
|
||||||
|
}
|
||||||
|
.view,.text{
|
||||||
|
font-size:28rpx;
|
||||||
|
line-height:1.8;
|
||||||
|
color:#0E151D;
|
||||||
|
}
|
||||||
|
/* 宽度 */
|
||||||
|
.w-100{ width: 750rpx; }
|
||||||
|
|
||||||
|
.row {
|
||||||
|
margin-right: -20rpx;
|
||||||
|
margin-left: -20rpx;
|
||||||
|
/* #ifndef APP-PLUS-NVUE */
|
||||||
|
display: flex;
|
||||||
|
/* #endif */
|
||||||
|
flex-wrap: wrap;
|
||||||
|
flex-direction: row;
|
||||||
|
}
|
||||||
|
|
||||||
|
.col-1,
|
||||||
|
.col-2,
|
||||||
|
.col-3,
|
||||||
|
.col-4,
|
||||||
|
.col-5,
|
||||||
|
.col-6,
|
||||||
|
.col-7,
|
||||||
|
.col-8,
|
||||||
|
.col-9,
|
||||||
|
.col-10,
|
||||||
|
.col-11,
|
||||||
|
.col-12{
|
||||||
|
position: relative;
|
||||||
|
padding-right: 20rpx;
|
||||||
|
padding-left: 20rpx;
|
||||||
|
}
|
||||||
|
.col-12 { width: 750rpx;}
|
||||||
|
.col-11 { width: 687.5rpx; }
|
||||||
|
.col-10 { width: 625rpx; }
|
||||||
|
.col-9 { width: 562.5rpx; }
|
||||||
|
.col-8 { width: 500rpx; }
|
||||||
|
.col-7 { width: 437.5rpx; }
|
||||||
|
.col-6 { width: 375rpx; }
|
||||||
|
.col-5 { width: 312.5rpx;}
|
||||||
|
.col-4 {width: 250rpx;}
|
||||||
|
.col-3 {width: 187.5rpx;}
|
||||||
|
.col-2 {width: 125rpx;}
|
||||||
|
.col-1 {width: 62.5rpx;}
|
||||||
|
|
||||||
|
.col-offset-12 { margin-left: 750rpx;}
|
||||||
|
.col-offset-11 { margin-left: 687.5rpx; }
|
||||||
|
.col-offset-10 { margin-left: 625rpx; }
|
||||||
|
.col-offset-9 { margin-left: 562.5rpx; }
|
||||||
|
.col-offset-8 { margin-left: 500rpx; }
|
||||||
|
.col-offset-7 { margin-left: 437.5rpx; }
|
||||||
|
.col-offset-6 { margin-left: 375rpx; }
|
||||||
|
.col-offset-5 { margin-left: 312.5rpx;}
|
||||||
|
.col-offset-4 {margin-left: 250rpx;}
|
||||||
|
.col-offset-3 {margin-left: 187.5rpx;}
|
||||||
|
.col-offset-2 {margin-left: 125rpx;}
|
||||||
|
.col-offset-1 {margin-left: 62.5rpx;}
|
||||||
|
.col-offset-0 {margin-left: 0;}
|
||||||
|
|
||||||
|
/* flex 布局 */
|
||||||
|
.flex{
|
||||||
|
/* #ifndef APP-PLUS-NVUE */
|
||||||
|
display:flex;
|
||||||
|
/* #endif */
|
||||||
|
flex-direction:row;
|
||||||
|
}
|
||||||
|
.flex-row{ flex-direction:row!important; }
|
||||||
|
.flex-column{ flex-direction:column!important; }
|
||||||
|
.flex-row-reverse{ flex-direction:row-reverse!important; }
|
||||||
|
.flex-column-reverse{ flex-direction:column-reverse!important; }
|
||||||
|
.flex-wrap{ flex-wrap:wrap;}
|
||||||
|
.flex-nowrap{ flex-wrap:nowrap;}
|
||||||
|
.justify-start{justify-content:flex-start;}
|
||||||
|
.justify-end{justify-content:flex-end;}
|
||||||
|
.justify-between{justify-content:space-between;}
|
||||||
|
.justify-center{justify-content:center;}
|
||||||
|
.align-center{ align-items: center; }
|
||||||
|
.align-stretch{ align-items: stretch; }
|
||||||
|
.align-start{ align-items: flex-start; }
|
||||||
|
.align-end{ align-items: flex-end; }
|
||||||
|
/* #ifndef APP-PLUS-NVUE */
|
||||||
|
.content-start {align-content: flex-start;}
|
||||||
|
.content-end {align-content: flex-end;}
|
||||||
|
.content-center {align-content: center;}
|
||||||
|
.content-between {align-content: space-between;}
|
||||||
|
.content-around {align-content: space-around;}
|
||||||
|
.content-stretch {align-content: stretch;}
|
||||||
|
/* #endif */
|
||||||
|
.flex-1{ flex: 1; }
|
||||||
|
.flex-2{ flex: 2; }
|
||||||
|
.flex-3{ flex: 3; }
|
||||||
|
.flex-4{ flex: 4; }
|
||||||
|
.flex-5{ flex: 5; }
|
||||||
|
/* #ifndef APP-PLUS-NVUE */
|
||||||
|
.flex-shrink{ flex-shrink: 0; }
|
||||||
|
/* #endif */
|
||||||
|
|
||||||
|
.container {
|
||||||
|
padding-right: 20rpx;
|
||||||
|
padding-left: 20rpx;
|
||||||
|
}
|
||||||
|
/* -- 内外边距 -- */
|
||||||
|
.m-0 { margin: 0; }
|
||||||
|
/* #ifndef APP-PLUS-NVUE */
|
||||||
|
.m-auto{ margin: auto; }
|
||||||
|
/* #endif */
|
||||||
|
.m-1 { margin: 10rpx; }
|
||||||
|
.m-2 { margin: 20rpx; }
|
||||||
|
.m-3 { margin: 30rpx; }
|
||||||
|
.m-4 { margin: 40rpx; }
|
||||||
|
.m-5 { margin: 50rpx; }
|
||||||
|
.mt-0 { margin-top: 0; }
|
||||||
|
/* #ifndef APP-PLUS-NVUE */
|
||||||
|
.mt-auto { margin-top: auto; }
|
||||||
|
/* #endif */
|
||||||
|
.mt-1 { margin-top: 10rpx; }
|
||||||
|
.mt-2 { margin-top: 20rpx; }
|
||||||
|
.mt-3 { margin-top: 30rpx; }
|
||||||
|
.mt-4 { margin-top: 40rpx; }
|
||||||
|
.mt-5 { margin-top: 50rpx; }
|
||||||
|
.mb-0 { margin-bottom: 0; }
|
||||||
|
/* #ifndef APP-PLUS-NVUE */
|
||||||
|
.mb-auto { margin-bottom: auto; }
|
||||||
|
/* #endif */
|
||||||
|
.mb-1 { margin-bottom: 10rpx; }
|
||||||
|
.mb-2 { margin-bottom: 20rpx; }
|
||||||
|
.mb-3 { margin-bottom: 30rpx; }
|
||||||
|
.mb-4 { margin-bottom: 40rpx; }
|
||||||
|
.mb-5 { margin-bottom: 50rpx; }
|
||||||
|
.ml-0 { margin-left: 0; }
|
||||||
|
/* #ifndef APP-PLUS-NVUE */
|
||||||
|
.ml-auto { margin-left: auto; }
|
||||||
|
/* #endif */
|
||||||
|
.ml-1 { margin-left: 10rpx; }
|
||||||
|
.ml-2 { margin-left: 20rpx; }
|
||||||
|
.ml-3 { margin-left: 30rpx; }
|
||||||
|
.ml-4 { margin-left: 40rpx; }
|
||||||
|
.ml-5 { margin-left: 50rpx; }
|
||||||
|
.mr-0 { margin-right: 0; }
|
||||||
|
/* #ifndef APP-PLUS-NVUE */
|
||||||
|
.mr-auto { margin-right: auto; }
|
||||||
|
/* #endif */
|
||||||
|
.mr-1 { margin-right: 10rpx; }
|
||||||
|
.mr-2 { margin-right: 20rpx; }
|
||||||
|
.mr-3 { margin-right: 30rpx; }
|
||||||
|
.mr-4 { margin-right: 40rpx; }
|
||||||
|
.mr-5 { margin-right: 50rpx; }
|
||||||
|
.my-0 { margin-top: 0; margin-bottom: 0; }
|
||||||
|
/* #ifndef APP-PLUS-NVUE */
|
||||||
|
.my-auto { margin-top: auto; margin-bottom: auto; }
|
||||||
|
/* #endif */
|
||||||
|
.my-1 { margin-top: 10rpx; margin-bottom: 10rpx; }
|
||||||
|
.my-2 { margin-top: 20rpx; margin-bottom: 20rpx; }
|
||||||
|
.my-3 { margin-top: 30rpx; margin-bottom: 30rpx; }
|
||||||
|
.my-4 { margin-top: 40rpx; margin-bottom: 40rpx; }
|
||||||
|
.my-5 { margin-top: 50rpx; margin-bottom: 50rpx; }
|
||||||
|
.mx-0 { margin-left: 0; margin-right: 0; }
|
||||||
|
/* #ifndef APP-PLUS-NVUE */
|
||||||
|
.mx-auto { margin-left: auto; margin-right: auto; }
|
||||||
|
/* #endif */
|
||||||
|
.mx-1 { margin-left: 10rpx; margin-right: 10rpx;}
|
||||||
|
.mx-2 { margin-left: 20rpx; margin-right: 20rpx;}
|
||||||
|
.mx-3 { margin-left: 30rpx; margin-right: 30rpx;}
|
||||||
|
.mx-4 { margin-left: 40rpx; margin-right: 40rpx;}
|
||||||
|
.mx-5 { margin-left: 50rpx; margin-right: 50rpx;}
|
||||||
|
|
||||||
|
.p-0 { padding: 0; }
|
||||||
|
.p { padding: 5rpx; }
|
||||||
|
.p-1 { padding: 10rpx; }
|
||||||
|
.p-2 { padding: 20rpx; }
|
||||||
|
.p-3 { padding: 30rpx; }
|
||||||
|
.p-4 { padding: 40rpx; }
|
||||||
|
.p-5 { padding: 50rpx; }
|
||||||
|
.pt-0 { padding-top: 0; }
|
||||||
|
.pt { padding-top: 5rpx; }
|
||||||
|
.pt-1 { padding-top: 10rpx; }
|
||||||
|
.pt-2 { padding-top: 20rpx; }
|
||||||
|
.pt-3 { padding-top: 30rpx; }
|
||||||
|
.pt-4 { padding-top: 40rpx; }
|
||||||
|
.pt-5 { padding-top: 50rpx; }
|
||||||
|
.pb-0 { padding-bottom: 0; }
|
||||||
|
.pb-1 { padding-bottom: 10rpx; }
|
||||||
|
.pb { padding-bottom: 5rpx; }
|
||||||
|
.pb-2 { padding-bottom: 20rpx; }
|
||||||
|
.pb-3 { padding-bottom: 30rpx; }
|
||||||
|
.pb-4 { padding-bottom: 40rpx; }
|
||||||
|
.pb-5 { padding-bottom: 50rpx; }
|
||||||
|
.pl-0 { padding-left: 0; }
|
||||||
|
.pl { padding-left: 5rpx; }
|
||||||
|
.pl-1 { padding-left: 10rpx; }
|
||||||
|
.pl-2 { padding-left: 20rpx; }
|
||||||
|
.pl-3 { padding-left: 30rpx; }
|
||||||
|
.pl-4 { padding-left: 40rpx; }
|
||||||
|
.pl-5 { padding-left: 50rpx; }
|
||||||
|
.pr-0 { padding-right: 0; }
|
||||||
|
.pr { padding-right: 5rpx; }
|
||||||
|
.pr-1 { padding-right: 10rpx; }
|
||||||
|
.pr-2 { padding-right: 20rpx; }
|
||||||
|
.pr-3 { padding-right: 30rpx; }
|
||||||
|
.pr-4 { padding-right: 40rpx; }
|
||||||
|
.pr-5 { padding-right: 50rpx; }
|
||||||
|
.py-0 { padding-top: 0; padding-bottom: 0; }
|
||||||
|
.py { padding-top: 5rpx; padding-bottom: 5rpx; }
|
||||||
|
.py-1 { padding-top: 10rpx; padding-bottom: 10rpx; }
|
||||||
|
.py-2 { padding-top: 20rpx; padding-bottom: 20rpx; }
|
||||||
|
.py-3 { padding-top: 30rpx; padding-bottom: 30rpx; }
|
||||||
|
.py-4 { padding-top: 40rpx; padding-bottom: 40rpx; }
|
||||||
|
.py-5 { padding-top: 50rpx; padding-bottom: 50rpx; }
|
||||||
|
.px-0 { padding-left: 0; padding-right: 0; }
|
||||||
|
.px-1 { padding-left: 10rpx; padding-right: 10rpx;}
|
||||||
|
.px { padding-left: 5rpx; padding-right: 5rpx;}
|
||||||
|
.px-2 { padding-left: 20rpx; padding-right: 20rpx;}
|
||||||
|
.px-3 { padding-left: 30rpx; padding-right: 30rpx;}
|
||||||
|
.px-4 { padding-left: 40rpx; padding-right: 40rpx;}
|
||||||
|
.px-5 { padding-left: 50rpx; padding-right: 50rpx;}
|
||||||
|
/* 文字大小 */
|
||||||
|
.font-small { font-size: 20upx;}
|
||||||
|
.font-sm { font-size: 25upx;}
|
||||||
|
.font { font-size: 30upx;}
|
||||||
|
.font-md { font-size: 35upx;}
|
||||||
|
.font-lg { font-size: 40upx;}
|
||||||
|
.h1{font-size:80upx; line-height:1.8;}
|
||||||
|
.h2{font-size:60upx; line-height:1.8;}
|
||||||
|
.h3{font-size:45upx; line-height:1.8;}
|
||||||
|
.h4{font-size:32upx; line-height:1.8;}
|
||||||
|
.h5{font-size:30upx; line-height:1.8;}
|
||||||
|
.h6{font-size:28upx; line-height:1.8;}
|
||||||
|
/* 文字缩进 */
|
||||||
|
/* #ifndef APP-PLUS-NVUE */
|
||||||
|
.text-indent{text-indent:2;}
|
||||||
|
/* #endif */
|
||||||
|
/* 文字划线 */
|
||||||
|
.text-through{text-decoration:line-through;}
|
||||||
|
/* 文字对齐 */
|
||||||
|
.text-left { text-align: left;}
|
||||||
|
.text-right { text-align: right;}
|
||||||
|
.text-center { text-align: center;}
|
||||||
|
/* 文字换行溢出处理 */
|
||||||
|
.text-ellipsis {
|
||||||
|
/* #ifndef APP-PLUS-NVUE */
|
||||||
|
overflow: hidden;text-overflow: ellipsis;white-space: nowrap;
|
||||||
|
/* #endif */
|
||||||
|
/* #ifdef APP-PLUS-NVUE */
|
||||||
|
lines: 1;
|
||||||
|
/* #endif */
|
||||||
|
}
|
||||||
|
/* 文字粗细和斜体 */
|
||||||
|
.font-weight-light {font-weight: 300;} /*细*/
|
||||||
|
.font-weight-lighter {font-weight: 100;}/*更细*/
|
||||||
|
.font-weight-normal { font-weight: 400;} /*正常*/
|
||||||
|
.font-weight-bold { font-weight: 700;} /*粗*/
|
||||||
|
.font-weight-bolder { font-weight: bold;} /*更粗*/
|
||||||
|
.font-italic { font-style: italic;} /*斜体*/
|
||||||
|
/* 文字颜色 */
|
||||||
|
.text-white {color: #ffffff;}
|
||||||
|
.text-primary {color: #007bff;}
|
||||||
|
.text-hover-primary { color: #0056b3;}
|
||||||
|
.text-secondary {color: #6c757d;}
|
||||||
|
.text-hover-secondary { color: #494f54;}
|
||||||
|
.text-success {color: #28a745;}
|
||||||
|
.text-hover-success{color: #19692c;}
|
||||||
|
.text-info { color: #17a2b8;}
|
||||||
|
.text-hover-info {color: #0f6674;}
|
||||||
|
.text-warning {color: #ffc107;}
|
||||||
|
.text-hover-warning { color: #ba8b00;}
|
||||||
|
.text-danger { color: #dc3545;}
|
||||||
|
.text-hover-danger { color: #a71d2a;}
|
||||||
|
.text-light { color: #f8f9fa;}
|
||||||
|
.text-hover-light { color: #cbd3da;}
|
||||||
|
.text-dark { color: #343a40;}
|
||||||
|
.text-hover-dark{ color: #121416;}
|
||||||
|
.text-body { color: #212529;}
|
||||||
|
.text-muted { color: #6c757d;}
|
||||||
|
.text-light-muted { color: #A9A5A0;}
|
||||||
|
.text-light-black { color: rgba(0, 0, 0, 0.5);}
|
||||||
|
.text-light-white { color: rgba(255, 255, 255, 0.5);}
|
||||||
|
|
||||||
|
/* 背景颜色 */
|
||||||
|
.bg-primary { background-color: #007bff;}
|
||||||
|
.bg-hover-primary:hover{ background-color: #0062cc;}
|
||||||
|
.bg-secondary { background-color: #6c757d;}
|
||||||
|
.bg-hover-secondary:hover{ background-color: #545b62;}
|
||||||
|
.bg-success { background-color: #28a745;}
|
||||||
|
.bg-hover-success { background-color: #1e7e34;}
|
||||||
|
.bg-info { background-color: #17a2b8;}
|
||||||
|
.bg-hover-info { background-color: #117a8b;}
|
||||||
|
.bg-warning { background-color: #ffc107;}
|
||||||
|
.bg-hover-warning { background-color: #d39e00;}
|
||||||
|
.bg-danger { background-color: #dc3545;}
|
||||||
|
.bg-hover-danger{ background-color: #bd2130;}
|
||||||
|
.bg-light { background-color: #f8f9fa;}
|
||||||
|
.bg-hover-light{ background-color: #dae0e5;}
|
||||||
|
.bg-dark { background-color: #343a40;}
|
||||||
|
.bg-hover-dark { background-color: #1d2124;}
|
||||||
|
.bg-white { background-color: #ffffff;}
|
||||||
|
.bg-transparent { background-color: transparent;}
|
||||||
|
/* 边框 */
|
||||||
|
.border { border-width: 1rpx;border-style: solid;border-color: #dee2e6;}
|
||||||
|
.border-top {
|
||||||
|
border-top-width: 1rpx;
|
||||||
|
border-top-style: solid;
|
||||||
|
border-top-color: #dee2e6;
|
||||||
|
}
|
||||||
|
.border-right {
|
||||||
|
border-right-width: 1rpx;
|
||||||
|
border-right-style: solid;
|
||||||
|
border-right-color: #dee2e6;
|
||||||
|
}
|
||||||
|
.border-bottom {
|
||||||
|
border-bottom-width: 1rpx;
|
||||||
|
border-bottom-style: solid;
|
||||||
|
border-bottom-color: #dee2e6;
|
||||||
|
}
|
||||||
|
.border-left {
|
||||||
|
border-left-width: 1rpx;
|
||||||
|
border-left-style: solid;
|
||||||
|
border-left-color: #dee2e6;
|
||||||
|
}
|
||||||
|
.border-0 { border-width: 0!important;}
|
||||||
|
.border-top-0 { border-top-width: 0!important;}
|
||||||
|
.border-right-0 {border-right-width: 0!important;}
|
||||||
|
.border-bottom-0 {border-bottom-width: 0!important;}
|
||||||
|
.border-left-0 {border-left-width: 0!important;}
|
||||||
|
.border-primary { border-color: #007bff;}
|
||||||
|
.border-secondary {border-color: #6c757d;}
|
||||||
|
.border-light-secondary {border-color: #E9E8E5;}
|
||||||
|
.border-success {border-color: #28a745;}
|
||||||
|
.border-info {border-color: #17a2b8;}
|
||||||
|
.border-warning {border-color: #ffc107;}
|
||||||
|
.border-danger {border-color: #dc3545;}
|
||||||
|
.border-light {border-color: #f8f9fa;}
|
||||||
|
.border-dark {border-color: #343a40;}
|
||||||
|
.border-white {border-color: #FFFFFF;}
|
||||||
|
/* 圆角 */
|
||||||
|
.rounded { border-radius: 8rpx;}
|
||||||
|
.rounded-top {
|
||||||
|
border-top-left-radius: 8rpx;
|
||||||
|
border-top-right-radius: 8rpx;
|
||||||
|
}
|
||||||
|
.rounded-right {
|
||||||
|
border-top-right-radius: 8rpx;
|
||||||
|
border-bottom-right-radius: 8rpx;
|
||||||
|
}
|
||||||
|
.rounded-bottom {
|
||||||
|
border-bottom-right-radius: 8rpx;
|
||||||
|
border-bottom-left-radius: 8rpx;
|
||||||
|
}
|
||||||
|
.rounded-left {
|
||||||
|
border-top-left-radius: 8rpx;
|
||||||
|
border-bottom-left-radius: 8rpx;
|
||||||
|
}
|
||||||
|
.rounded-circle { border-radius: 100rpx;}
|
||||||
|
.rounded-0 { border-radius: 0;}
|
||||||
|
/* 显示 */
|
||||||
|
/* #ifndef APP-PLUS-NVUE */
|
||||||
|
.d-none{ display: none; }
|
||||||
|
.d-inline-block{ display: inline-block; }
|
||||||
|
.d-block{ display: block; }
|
||||||
|
/* #endif */
|
||||||
|
/* 内容溢出 */
|
||||||
|
.overflow-hidden { overflow: hidden;}
|
||||||
|
/* 定位 */
|
||||||
|
.position-relative { position: relative;}
|
||||||
|
.position-absolute { position: absolute;}
|
||||||
|
.position-fixed { position: fixed;}
|
||||||
|
/* 定位 - 固定顶部 */
|
||||||
|
.fixed-top {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
right: 0;
|
||||||
|
left: 0;
|
||||||
|
z-index: 1030;
|
||||||
|
}
|
||||||
|
/* 定位 - 固定底部 */
|
||||||
|
.fixed-bottom {
|
||||||
|
position: fixed;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
z-index: 1030;
|
||||||
|
}
|
||||||
|
.top-0 { top: 0; }
|
||||||
|
.left-0 { left: 0; }
|
||||||
|
.right-0 { right: 0; }
|
||||||
|
.bottom-0 { bottom: 0; }
|
||||||
|
|
||||||
|
/* 阴影 */
|
||||||
|
/* #ifndef APP-PLUS-NVUE */
|
||||||
|
.shadow { box-shadow: 0 2upx 12upx rgba(0, 0, 0, 0.15);}
|
||||||
|
.shadow-lg { box-shadow: 0upx 40upx 100upx 0upx rgba(0, 0, 0, 0.175);}
|
||||||
|
.shadow-none { box-shadow: none !important;}
|
||||||
|
/* #endif */
|
||||||
|
|
||||||
BIN
app-sqlite-master/app-sqlite/font.ttf
Normal file
BIN
app-sqlite-master/app-sqlite/font.ttf
Normal file
Binary file not shown.
20
app-sqlite-master/app-sqlite/index.html
Normal file
20
app-sqlite-master/app-sqlite/index.html
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<script>
|
||||||
|
var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') ||
|
||||||
|
CSS.supports('top: constant(a)'))
|
||||||
|
document.write(
|
||||||
|
'<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' +
|
||||||
|
(coverSupport ? ', viewport-fit=cover' : '') + '" />')
|
||||||
|
</script>
|
||||||
|
<title></title>
|
||||||
|
<!--preload-links-->
|
||||||
|
<!--app-context-->
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="app"><!--app-html--></div>
|
||||||
|
<script type="module" src="/main.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
12
app-sqlite-master/app-sqlite/main.js
Normal file
12
app-sqlite-master/app-sqlite/main.js
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
import Vue from 'vue'
|
||||||
|
import App from './App'
|
||||||
|
|
||||||
|
|
||||||
|
Vue.config.productionTip = false
|
||||||
|
|
||||||
|
App.mpType = 'app'
|
||||||
|
|
||||||
|
const app = new Vue({
|
||||||
|
...App
|
||||||
|
})
|
||||||
|
app.$mount()
|
||||||
88
app-sqlite-master/app-sqlite/manifest.json
Normal file
88
app-sqlite-master/app-sqlite/manifest.json
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
{
|
||||||
|
"name" : "l-im-app",
|
||||||
|
"appid" : "__UNI__621989A",
|
||||||
|
"description" : "l-im-app",
|
||||||
|
"versionName" : "1.0.0",
|
||||||
|
"versionCode" : "100",
|
||||||
|
"transformPx" : false,
|
||||||
|
/* 5+App特有相关 */
|
||||||
|
"app-plus" : {
|
||||||
|
"nvueCompiler" : "uni-app",
|
||||||
|
"usingComponents" : true,
|
||||||
|
"splashscreen" : {
|
||||||
|
"alwaysShowBeforeRender" : true,
|
||||||
|
"waiting" : true,
|
||||||
|
"autoclose" : true,
|
||||||
|
"delay" : 0
|
||||||
|
},
|
||||||
|
/* 模块配置 */
|
||||||
|
"modules" : {
|
||||||
|
"VideoPlayer" : {},
|
||||||
|
"SQLite" : {}
|
||||||
|
},
|
||||||
|
/* 应用发布信息 */
|
||||||
|
"distribute" : {
|
||||||
|
/* android打包配置 */
|
||||||
|
"android" : {
|
||||||
|
"permissions" : [
|
||||||
|
"<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
|
||||||
|
"<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
|
||||||
|
"<uses-permission android:name=\"android.permission.READ_CONTACTS\"/>",
|
||||||
|
"<uses-permission android:name=\"android.permission.VIBRATE\"/>",
|
||||||
|
"<uses-permission android:name=\"android.permission.READ_LOGS\"/>",
|
||||||
|
"<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>",
|
||||||
|
"<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
|
||||||
|
"<uses-permission android:name=\"android.permission.WRITE_CONTACTS\"/>",
|
||||||
|
"<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>",
|
||||||
|
"<uses-permission android:name=\"android.permission.CAMERA\"/>",
|
||||||
|
"<uses-permission android:name=\"android.permission.RECORD_AUDIO\"/>",
|
||||||
|
"<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>",
|
||||||
|
"<uses-permission android:name=\"android.permission.MODIFY_AUDIO_SETTINGS\"/>",
|
||||||
|
"<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>",
|
||||||
|
"<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>",
|
||||||
|
"<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",
|
||||||
|
"<uses-permission android:name=\"android.permission.CALL_PHONE\"/>",
|
||||||
|
"<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>",
|
||||||
|
"<uses-permission android:name=\"android.permission.ACCESS_COARSE_LOCATION\"/>",
|
||||||
|
"<uses-feature android:name=\"android.hardware.camera\"/>",
|
||||||
|
"<uses-permission android:name=\"android.permission.ACCESS_FINE_LOCATION\"/>",
|
||||||
|
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
/* ios打包配置 */
|
||||||
|
"ios" : {
|
||||||
|
"UIBackgroundModes" : "audio",
|
||||||
|
"idfa" : false
|
||||||
|
},
|
||||||
|
/* SDK配置 */
|
||||||
|
"sdkConfigs" : {}
|
||||||
|
},
|
||||||
|
"compilerVersion" : 3,
|
||||||
|
"renderer" : "native"
|
||||||
|
},
|
||||||
|
/* 快应用特有相关 */
|
||||||
|
"quickapp" : {},
|
||||||
|
/* 小程序特有相关 */
|
||||||
|
"mp-weixin" : {
|
||||||
|
"appid" : "",
|
||||||
|
"setting" : {
|
||||||
|
"urlCheck" : false
|
||||||
|
},
|
||||||
|
"usingComponents" : true
|
||||||
|
},
|
||||||
|
"mp-alipay" : {
|
||||||
|
"usingComponents" : true
|
||||||
|
},
|
||||||
|
"mp-baidu" : {
|
||||||
|
"usingComponents" : true
|
||||||
|
},
|
||||||
|
"mp-toutiao" : {
|
||||||
|
"usingComponents" : true
|
||||||
|
},
|
||||||
|
"uniStatistics" : {
|
||||||
|
"enable" : false
|
||||||
|
},
|
||||||
|
"vueVersion" : "2"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
20
app-sqlite-master/app-sqlite/pages.json
Normal file
20
app-sqlite-master/app-sqlite/pages.json
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"pages": [
|
||||||
|
//pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
|
||||||
|
{
|
||||||
|
"path": "pages/common/study/study",
|
||||||
|
"style": {}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"globalStyle": {
|
||||||
|
"navigationBarTextStyle": "black",
|
||||||
|
"navigationBarTitleText": "l-im-app",
|
||||||
|
"navigationBarBackgroundColor": "#F8F8F8",
|
||||||
|
"backgroundColor": "#F8F8F8",
|
||||||
|
"app-plus": {
|
||||||
|
"titleNView": false,
|
||||||
|
"scrollIndicator": "none"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"uniIdRouter": {}
|
||||||
|
}
|
||||||
92
app-sqlite-master/app-sqlite/pages/common/study/study.nvue
Normal file
92
app-sqlite-master/app-sqlite/pages/common/study/study.nvue
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
<template>
|
||||||
|
<view>
|
||||||
|
|
||||||
|
<view>
|
||||||
|
<view class="flex align-center justify-center" style="height: 350rpx;">
|
||||||
|
<text style="font-size: 50rpx;">lld-im</text>
|
||||||
|
</view>
|
||||||
|
<view class="p-3 flex align-center justify-center">
|
||||||
|
<view class="main-bg-color rounded p-3 flex align-center justify-center flex-1"
|
||||||
|
hover-class="main-bg-hover-color" @click="getAllFriend()">
|
||||||
|
<text class="text-white font-md">拉取所有好友资料</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view class="p-3 flex align-center justify-center">
|
||||||
|
<view class="main-bg-color rounded p-3 flex align-center justify-center flex-1"
|
||||||
|
hover-class="main-bg-hover-color" @click="getSyncFriend()">
|
||||||
|
<text class="text-white font-md">增量拉取好友资料好友资料</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view class="p-3 flex align-center justify-center">
|
||||||
|
<view class="main-bg-color rounded p-3 flex align-center justify-center flex-1"
|
||||||
|
hover-class="main-bg-hover-color" @click="clearAllFriend(seq)">
|
||||||
|
<text class="text-white font-md">清空所有好友数据</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import $H from '@/common/lib/request.js';
|
||||||
|
import sqlite from "@/store/modules/sql.js"
|
||||||
|
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
console.log("createTable")
|
||||||
|
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
getAllFriend() {
|
||||||
|
$H.post('/friendship/getAllFriendShip', {
|
||||||
|
appId: 10000,
|
||||||
|
fromId: "lld"
|
||||||
|
}, {
|
||||||
|
token: false
|
||||||
|
}).then(res => {
|
||||||
|
sqlite.bathAddFriend(res.data);
|
||||||
|
})
|
||||||
|
},
|
||||||
|
getSyncFriend() {
|
||||||
|
sqlite.getFriendMaxSeq("lld",10000).then(res => {
|
||||||
|
var maxSeq = res[0].maxSeq;
|
||||||
|
$H.post('/friendship/syncFriendShipList', {
|
||||||
|
appId: 10000,
|
||||||
|
operater: "lld",
|
||||||
|
lastSequence:maxSeq,
|
||||||
|
maxLimit:100
|
||||||
|
}, {
|
||||||
|
token: false
|
||||||
|
}).then(res => {
|
||||||
|
console.log(res)
|
||||||
|
})
|
||||||
|
});
|
||||||
|
},
|
||||||
|
clearAllFriend() {
|
||||||
|
sqlite.clearAllFriend();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
|
||||||
|
},
|
||||||
|
onShow() {
|
||||||
|
if (!sqlite.isOpen("main", "/sdcard/Pictures/sql.db")) {
|
||||||
|
sqlite.openSqlite();
|
||||||
|
}
|
||||||
|
sqlite.createTable().then(res => {
|
||||||
|
console.log(res)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
|
||||||
|
</style>
|
||||||
194
app-sqlite-master/app-sqlite/store/modules/sql.js
Normal file
194
app-sqlite-master/app-sqlite/store/modules/sql.js
Normal file
@@ -0,0 +1,194 @@
|
|||||||
|
let sqlite = {
|
||||||
|
//创建数据库或者有该数据库就打开
|
||||||
|
openSqlite: function() {
|
||||||
|
//创建数据库或者打开
|
||||||
|
//这plus.sqlite只在手机上运行
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
console.log("打开数据库");
|
||||||
|
plus.sqlite.openDatabase({
|
||||||
|
name: "main", //数据库名称
|
||||||
|
path: "_doc/sql.db", //数据库地址,uniapp推荐以下划线为开头,这到底存在哪里去了,我也不清楚,哈哈
|
||||||
|
success(e) {
|
||||||
|
console.log("success")
|
||||||
|
resolve(e); //成功回调
|
||||||
|
},
|
||||||
|
fail(e) {
|
||||||
|
console.log(e)
|
||||||
|
reject(e); //失败回调
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
getFriendMaxSeq: function(fromId, appId) {
|
||||||
|
|
||||||
|
var sql = "";
|
||||||
|
|
||||||
|
|
||||||
|
sql =
|
||||||
|
"select ifnull(max(friend_sequence),0) as maxSeq from im_friendship " +
|
||||||
|
" where app_id = " +
|
||||||
|
appId +
|
||||||
|
" and from_id = '" +
|
||||||
|
fromId + "'";
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
plus.sqlite.selectSql({
|
||||||
|
name: "main",
|
||||||
|
sql: sql,
|
||||||
|
success(e) {
|
||||||
|
console.log(e)
|
||||||
|
resolve(e);
|
||||||
|
},
|
||||||
|
fail(e) {
|
||||||
|
console.log(e)
|
||||||
|
reject(e);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
addFriend: function(fromId, toId, remark, status, black, friendSeq, blackSeq, addSource, ex, appId) {
|
||||||
|
var sql =
|
||||||
|
" insert into im_friendship(from_id,to_id,remark,status,black,friend_sequence,black_sequence,add_source,extra,app_id) " +
|
||||||
|
' values ("' +
|
||||||
|
fromId +
|
||||||
|
'","' +
|
||||||
|
toId +
|
||||||
|
'","' +
|
||||||
|
remark +
|
||||||
|
'","' +
|
||||||
|
status +
|
||||||
|
'","' +
|
||||||
|
black +
|
||||||
|
'","' +
|
||||||
|
friendSeq +
|
||||||
|
'","' +
|
||||||
|
blackSeq +
|
||||||
|
'","' +
|
||||||
|
addSource +
|
||||||
|
'","' +
|
||||||
|
123 +
|
||||||
|
'","' +
|
||||||
|
appId +
|
||||||
|
'")';
|
||||||
|
console.log(sql)
|
||||||
|
plus.sqlite.executeSql({
|
||||||
|
name: "main",
|
||||||
|
sql: sql,
|
||||||
|
success(e) {
|
||||||
|
console.log("插入成功")
|
||||||
|
resolve(e);
|
||||||
|
},
|
||||||
|
fail(e) {
|
||||||
|
console.log(e)
|
||||||
|
reject(e);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
bathAddFriend: function(data) {
|
||||||
|
// console.log(data)
|
||||||
|
var sql =
|
||||||
|
" insert into im_friendship(from_id,to_id,remark,status,black,friend_sequence,black_sequence,add_source,extra,app_id) values ";
|
||||||
|
for (var i = 0; i < data.length; i++) {
|
||||||
|
var f = data[i];
|
||||||
|
sql += ' ("' +
|
||||||
|
f.fromId +
|
||||||
|
'","' +
|
||||||
|
f.toId +
|
||||||
|
'","' +
|
||||||
|
f.remark +
|
||||||
|
'","' +
|
||||||
|
f.status +
|
||||||
|
'","' +
|
||||||
|
f.black +
|
||||||
|
'","' +
|
||||||
|
f.friendSequence +
|
||||||
|
'","' +
|
||||||
|
f.blackSequence +
|
||||||
|
'","' +
|
||||||
|
f.addSource +
|
||||||
|
'","' +
|
||||||
|
123 +
|
||||||
|
'","' +
|
||||||
|
f.appId +
|
||||||
|
'"),';
|
||||||
|
}
|
||||||
|
|
||||||
|
sql = sql.substring(0, sql.length - 1); //末尾是&
|
||||||
|
// console.log(sql)
|
||||||
|
plus.sqlite.executeSql({
|
||||||
|
name: "main",
|
||||||
|
sql: sql,
|
||||||
|
success(e) {
|
||||||
|
console.log("插入成功")
|
||||||
|
resolve(e);
|
||||||
|
},
|
||||||
|
fail(e) {
|
||||||
|
console.log(e)
|
||||||
|
reject(e);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
},
|
||||||
|
clearAllFriend: function() {
|
||||||
|
var sql = "delete from im_friendship"
|
||||||
|
plus.sqlite.executeSql({
|
||||||
|
name: "main",
|
||||||
|
sql: sql,
|
||||||
|
success(e) {
|
||||||
|
console.log("清除成功")
|
||||||
|
resolve(e);
|
||||||
|
},
|
||||||
|
fail(e) {
|
||||||
|
console.log(e)
|
||||||
|
reject(e);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
},
|
||||||
|
// ---------------------------------------------------监听数据库是否开启-----------------------------------------------------------------
|
||||||
|
//监听数据库是否开启
|
||||||
|
isOpen: function(name, path) {
|
||||||
|
var ss = name || "main";
|
||||||
|
var qq = path || "_doc/sql.db";
|
||||||
|
//数据库打开了就返回true,否则返回false
|
||||||
|
var open = plus.sqlite.isOpenDatabase({
|
||||||
|
name: ss,
|
||||||
|
path: qq,
|
||||||
|
});
|
||||||
|
return open;
|
||||||
|
},
|
||||||
|
|
||||||
|
// ---------------------------------------------------创建表----------------------------------------------------------------
|
||||||
|
|
||||||
|
//在该数据库里创建表格, 这一步也必须要!
|
||||||
|
//下面注释里说的都是说sql:'create table if not exists....这里
|
||||||
|
//userInfo是表格名,你也可以写其他的名,不能用数字作为表格名的开头!!!
|
||||||
|
//括号里是表格的结构,列,这里我写了四列,list,id,gender,avatar这四列
|
||||||
|
//list后面大写的英文是自动增加的意思,因为表格里的每一行必须有唯一标识
|
||||||
|
//这sql语句会数据库的应该都看的懂,我是前端菜鸡,所以详细说明以便跟我一样不懂sql的前端看
|
||||||
|
//"id" TEXT 意思是这一列放的值为字符串之类的,如果是想存数字之类的就改为INTEGER
|
||||||
|
//数据库不能存对象,数组
|
||||||
|
//创建 9、定位表(d_location)
|
||||||
|
createTable: function() {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
//创建表格在executeSql方法里写
|
||||||
|
plus.sqlite.executeSql({
|
||||||
|
name: "main",
|
||||||
|
//表格创建或者打开,后面为表格结构
|
||||||
|
sql: "create table if not exists im_friendship(\"from_id\" text(50) NOT NULL,\"to_id\" text(50),\"app_id\" INTEGER(10) NOT NULL,\"remark\" TEXT(50),\"status\" int(5),\"black\" int(5),\"friend_sequence\" bigint(20),\"black_sequence\" bigint(20),\"add_source\" TEXT(20),\"extra\" TEXT(2000),PRIMARY KEY (\"app_id\", \"from_id\", \"to_id\"))",
|
||||||
|
success(e) {
|
||||||
|
console.log("创建成功")
|
||||||
|
resolve(e);
|
||||||
|
},
|
||||||
|
fail(e) {
|
||||||
|
console.log(e)
|
||||||
|
console.log("创建失败")
|
||||||
|
reject(e);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
//把这些方法导出去
|
||||||
|
export default sqlite;
|
||||||
76
app-sqlite-master/app-sqlite/uni.scss
Normal file
76
app-sqlite-master/app-sqlite/uni.scss
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
/**
|
||||||
|
* 这里是uni-app内置的常用样式变量
|
||||||
|
*
|
||||||
|
* uni-app 官方扩展插件及插件市场(https://ext.dcloud.net.cn)上很多三方插件均使用了这些样式变量
|
||||||
|
* 如果你是插件开发者,建议你使用scss预处理,并在插件代码中直接使用这些变量(无需 import 这个文件),方便用户通过搭积木的方式开发整体风格一致的App
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 如果你是App开发者(插件使用者),你可以通过修改这些变量来定制自己的插件主题,实现自定义主题功能
|
||||||
|
*
|
||||||
|
* 如果你的项目同样使用了scss预处理,你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* 颜色变量 */
|
||||||
|
|
||||||
|
/* 行为相关颜色 */
|
||||||
|
$uni-color-primary: #007aff;
|
||||||
|
$uni-color-success: #4cd964;
|
||||||
|
$uni-color-warning: #f0ad4e;
|
||||||
|
$uni-color-error: #dd524d;
|
||||||
|
|
||||||
|
/* 文字基本颜色 */
|
||||||
|
$uni-text-color:#333;//基本色
|
||||||
|
$uni-text-color-inverse:#fff;//反色
|
||||||
|
$uni-text-color-grey:#999;//辅助灰色,如加载更多的提示信息
|
||||||
|
$uni-text-color-placeholder: #808080;
|
||||||
|
$uni-text-color-disable:#c0c0c0;
|
||||||
|
|
||||||
|
/* 背景颜色 */
|
||||||
|
$uni-bg-color:#ffffff;
|
||||||
|
$uni-bg-color-grey:#f8f8f8;
|
||||||
|
$uni-bg-color-hover:#f1f1f1;//点击状态颜色
|
||||||
|
$uni-bg-color-mask:rgba(0, 0, 0, 0.4);//遮罩颜色
|
||||||
|
|
||||||
|
/* 边框颜色 */
|
||||||
|
$uni-border-color:#c8c7cc;
|
||||||
|
|
||||||
|
/* 尺寸变量 */
|
||||||
|
|
||||||
|
/* 文字尺寸 */
|
||||||
|
$uni-font-size-sm:12px;
|
||||||
|
$uni-font-size-base:14px;
|
||||||
|
$uni-font-size-lg:16;
|
||||||
|
|
||||||
|
/* 图片尺寸 */
|
||||||
|
$uni-img-size-sm:20px;
|
||||||
|
$uni-img-size-base:26px;
|
||||||
|
$uni-img-size-lg:40px;
|
||||||
|
|
||||||
|
/* Border Radius */
|
||||||
|
$uni-border-radius-sm: 2px;
|
||||||
|
$uni-border-radius-base: 3px;
|
||||||
|
$uni-border-radius-lg: 6px;
|
||||||
|
$uni-border-radius-circle: 50%;
|
||||||
|
|
||||||
|
/* 水平间距 */
|
||||||
|
$uni-spacing-row-sm: 5px;
|
||||||
|
$uni-spacing-row-base: 10px;
|
||||||
|
$uni-spacing-row-lg: 15px;
|
||||||
|
|
||||||
|
/* 垂直间距 */
|
||||||
|
$uni-spacing-col-sm: 4px;
|
||||||
|
$uni-spacing-col-base: 8px;
|
||||||
|
$uni-spacing-col-lg: 12px;
|
||||||
|
|
||||||
|
/* 透明度 */
|
||||||
|
$uni-opacity-disabled: 0.3; // 组件禁用态的透明度
|
||||||
|
|
||||||
|
/* 文章场景相关 */
|
||||||
|
$uni-color-title: #2C405A; // 文章标题颜色
|
||||||
|
$uni-font-size-title:20px;
|
||||||
|
$uni-color-subtitle: #555555; // 二级标题颜色
|
||||||
|
$uni-font-size-subtitle:26px;
|
||||||
|
$uni-color-paragraph: #3F536E; // 文章段落颜色
|
||||||
|
$uni-font-size-paragraph:15px;
|
||||||
4
chapter-3-code-master/chapter-3-code/.gitignore
vendored
Normal file
4
chapter-3-code-master/chapter-3-code/.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
/.idea
|
||||||
|
/logs
|
||||||
|
/im-service/target
|
||||||
|
/im-common/target
|
||||||
0
chapter-3-code-master/chapter-3-code/README.md
Normal file
0
chapter-3-code-master/chapter-3-code/README.md
Normal file
52
chapter-3-code-master/chapter-3-code/im-common/pom.xml
Normal file
52
chapter-3-code-master/chapter-3-code/im-common/pom.xml
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<parent>
|
||||||
|
<artifactId>im-system</artifactId>
|
||||||
|
<groupId>com.lld</groupId>
|
||||||
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<artifactId>common</artifactId>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<java.version>1.8</java.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter</artifactId>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-logging</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.httpcomponents</groupId>
|
||||||
|
<artifactId>httpclient</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- commons -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.commons</groupId>
|
||||||
|
<artifactId>commons-lang3</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
|
||||||
|
</project>
|
||||||
@@ -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;
|
||||||
|
|
||||||
|
}
|
||||||
101
chapter-3-code-master/chapter-3-code/im-service/pom.xml
Normal file
101
chapter-3-code-master/chapter-3-code/im-service/pom.xml
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<parent>
|
||||||
|
<artifactId>im-system</artifactId>
|
||||||
|
<groupId>com.lld</groupId>
|
||||||
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<description>lld-im-service project</description>
|
||||||
|
<properties>
|
||||||
|
<java.version>1.8</java.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<artifactId>service</artifactId>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<!-- rabbitmq -->
|
||||||
|
<!-- <dependency>-->
|
||||||
|
<!-- <groupId>org.springframework.boot</groupId>-->
|
||||||
|
<!-- <artifactId>spring-boot-starter-amqp</artifactId>-->
|
||||||
|
<!-- </dependency>-->
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-validation</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- <dependency>-->
|
||||||
|
<!-- <groupId>com.github.sgroschupf</groupId>-->
|
||||||
|
<!-- <artifactId>zkclient</artifactId>-->
|
||||||
|
<!-- </dependency>-->
|
||||||
|
|
||||||
|
<!-- redis -->
|
||||||
|
<!-- <dependency>-->
|
||||||
|
<!-- <groupId>org.springframework.boot</groupId>-->
|
||||||
|
<!-- <artifactId>spring-boot-starter-data-redis</artifactId>-->
|
||||||
|
<!-- </dependency>-->
|
||||||
|
|
||||||
|
<!-- spring boot web -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- <dependency>-->
|
||||||
|
<!-- <groupId>com.lld</groupId>-->
|
||||||
|
<!-- <artifactId>codec</artifactId>-->
|
||||||
|
<!-- <version>1.0.0-SNAPSHOT</version>-->
|
||||||
|
<!-- </dependency>-->
|
||||||
|
|
||||||
|
<!-- hutool -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.hutool</groupId>
|
||||||
|
<artifactId>hutool-all</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!--MySQL JDBC驱动 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-jdbc</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!--MySQL -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>mysql</groupId>
|
||||||
|
<artifactId>mysql-connector-java</artifactId>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- mybatis plus -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.baomidou</groupId>
|
||||||
|
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.jeffreyning</groupId>
|
||||||
|
<artifactId>mybatisplus-plus</artifactId>
|
||||||
|
<version>1.5.1-RELEASE</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- common -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.lld</groupId>
|
||||||
|
<artifactId>common</artifactId>
|
||||||
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
</project>
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package com.lld.im.service;
|
||||||
|
|
||||||
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
|
@SpringBootApplication
|
||||||
|
@MapperScan("com.lld.im.service.*.dao.mapper")
|
||||||
|
public class Application {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(Application.class, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package com.lld.im.service.config;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description:
|
||||||
|
* @author: lld
|
||||||
|
* @version: 1.0
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
public class BeanConfig {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package com.lld.im.service.config;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||||
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description:
|
||||||
|
* @author: lld
|
||||||
|
* @version: 1.0
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
public class WebConfig implements WebMvcConfigurer {
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addCorsMappings(CorsRegistry registry) {
|
||||||
|
registry.addMapping("/**")
|
||||||
|
.allowedOrigins("*")
|
||||||
|
.allowedMethods("GET", "HEAD", "POST", "PUT", "DELETE", "OPTIONS")
|
||||||
|
.allowCredentials(true)
|
||||||
|
.maxAge(3600)
|
||||||
|
.allowedHeaders("*");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,110 @@
|
|||||||
|
package com.lld.im.service.exception;
|
||||||
|
|
||||||
|
import com.lld.im.common.BaseErrorCode;
|
||||||
|
import com.lld.im.common.ResponseVO;
|
||||||
|
import com.lld.im.common.exception.ApplicationException;
|
||||||
|
import org.hibernate.validator.internal.engine.path.PathImpl;
|
||||||
|
import org.springframework.validation.BindException;
|
||||||
|
import org.springframework.validation.BindingResult;
|
||||||
|
import org.springframework.validation.FieldError;
|
||||||
|
import org.springframework.validation.ObjectError;
|
||||||
|
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||||
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||||
|
|
||||||
|
import javax.validation.ConstraintViolation;
|
||||||
|
import javax.validation.ConstraintViolationException;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
@RestControllerAdvice
|
||||||
|
public class GlobalExceptionHandler {
|
||||||
|
|
||||||
|
|
||||||
|
@ExceptionHandler(value=Exception.class)
|
||||||
|
@ResponseBody
|
||||||
|
public ResponseVO unknowException(Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
ResponseVO resultBean =new ResponseVO();
|
||||||
|
resultBean.setCode(BaseErrorCode.SYSTEM_ERROR.getCode());
|
||||||
|
resultBean.setMsg(BaseErrorCode.SYSTEM_ERROR.getError());
|
||||||
|
/**
|
||||||
|
* 未知异常的话,这里写逻辑,发邮件,发短信都可以、、
|
||||||
|
*/
|
||||||
|
return resultBean;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validator 参数校验异常处理
|
||||||
|
*
|
||||||
|
* @param ex
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@ExceptionHandler(value = ConstraintViolationException.class)
|
||||||
|
@ResponseBody
|
||||||
|
public Object handleMethodArgumentNotValidException(ConstraintViolationException ex) {
|
||||||
|
|
||||||
|
Set<ConstraintViolation<?>> constraintViolations = ex.getConstraintViolations();
|
||||||
|
ResponseVO resultBean =new ResponseVO();
|
||||||
|
resultBean.setCode(BaseErrorCode.PARAMETER_ERROR.getCode());
|
||||||
|
for (ConstraintViolation<?> constraintViolation : constraintViolations) {
|
||||||
|
PathImpl pathImpl = (PathImpl) constraintViolation.getPropertyPath();
|
||||||
|
// 读取参数字段,constraintViolation.getMessage() 读取验证注解中的message值
|
||||||
|
String paramName = pathImpl.getLeafNode().getName();
|
||||||
|
String message = "参数{".concat(paramName).concat("}").concat(constraintViolation.getMessage());
|
||||||
|
resultBean.setMsg(message);
|
||||||
|
|
||||||
|
return resultBean;
|
||||||
|
}
|
||||||
|
resultBean.setMsg(BaseErrorCode.PARAMETER_ERROR.getError() + ex.getMessage());
|
||||||
|
return resultBean;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ExceptionHandler(ApplicationException.class)
|
||||||
|
@ResponseBody
|
||||||
|
public Object applicationExceptionHandler(ApplicationException e) {
|
||||||
|
// 使用公共的结果类封装返回结果, 这里我指定状态码为
|
||||||
|
ResponseVO resultBean =new ResponseVO();
|
||||||
|
resultBean.setCode(e.getCode());
|
||||||
|
resultBean.setMsg(e.getError());
|
||||||
|
return resultBean;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validator 参数校验异常处理
|
||||||
|
*
|
||||||
|
* @param ex
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@ExceptionHandler(value = BindException.class)
|
||||||
|
@ResponseBody
|
||||||
|
public Object handleException2(BindException ex) {
|
||||||
|
FieldError err = ex.getFieldError();
|
||||||
|
String message = "参数{".concat(err.getField()).concat("}").concat(err.getDefaultMessage());
|
||||||
|
ResponseVO resultBean =new ResponseVO();
|
||||||
|
resultBean.setCode(BaseErrorCode.PARAMETER_ERROR.getCode());
|
||||||
|
resultBean.setMsg(message);
|
||||||
|
return resultBean;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//json格式
|
||||||
|
@ExceptionHandler(value = MethodArgumentNotValidException.class)
|
||||||
|
@ResponseBody
|
||||||
|
public Object handleException1(MethodArgumentNotValidException ex) {
|
||||||
|
StringBuilder errorMsg = new StringBuilder();
|
||||||
|
BindingResult re = ex.getBindingResult();
|
||||||
|
for (ObjectError error : re.getAllErrors()) {
|
||||||
|
errorMsg.append(error.getDefaultMessage()).append(",");
|
||||||
|
}
|
||||||
|
errorMsg.delete(errorMsg.length() - 1, errorMsg.length());
|
||||||
|
|
||||||
|
ResponseVO resultBean =new ResponseVO();
|
||||||
|
resultBean.setCode(BaseErrorCode.PARAMETER_ERROR.getCode());
|
||||||
|
resultBean.setMsg(BaseErrorCode.PARAMETER_ERROR.getError() + " : " + errorMsg.toString());
|
||||||
|
return resultBean;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
package com.lld.im.service.friendship.controller;
|
||||||
|
|
||||||
|
import com.lld.im.common.ResponseVO;
|
||||||
|
import com.lld.im.service.friendship.model.req.*;
|
||||||
|
import com.lld.im.service.friendship.service.ImFriendService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("v1/friendship")
|
||||||
|
public class ImFriendShipController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
ImFriendService imFriendShipService;
|
||||||
|
|
||||||
|
@RequestMapping("/importFriendShip")
|
||||||
|
public ResponseVO importFriendShip(@RequestBody @Validated ImporFriendShipReq req, Integer appId){
|
||||||
|
req.setAppId(appId);
|
||||||
|
return imFriendShipService.importFriendShip(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/addFriend")
|
||||||
|
public ResponseVO addFriend(@RequestBody @Validated AddFriendReq req, Integer appId){
|
||||||
|
req.setAppId(appId);
|
||||||
|
return imFriendShipService.addFriend(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/updateFriend")
|
||||||
|
public ResponseVO updateFriend(@RequestBody @Validated UpdateFriendReq req, Integer appId){
|
||||||
|
req.setAppId(appId);
|
||||||
|
return imFriendShipService.updateFriend(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/deleteFriend")
|
||||||
|
public ResponseVO deleteFriend(@RequestBody @Validated DeleteFriendReq req, Integer appId){
|
||||||
|
req.setAppId(appId);
|
||||||
|
return imFriendShipService.deleteFriend(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/deleteAllFriend")
|
||||||
|
public ResponseVO deleteAllFriend(@RequestBody @Validated DeleteFriendReq req, Integer appId){
|
||||||
|
req.setAppId(appId);
|
||||||
|
return imFriendShipService.deleteAllFriend(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/getAllFriendShip")
|
||||||
|
public ResponseVO getAllFriendShip(@RequestBody @Validated GetAllFriendShipReq req, Integer appId){
|
||||||
|
req.setAppId(appId);
|
||||||
|
return imFriendShipService.getAllFriendShip(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/getRelation")
|
||||||
|
public ResponseVO getRelation(@RequestBody @Validated GetRelationReq req, Integer appId){
|
||||||
|
req.setAppId(appId);
|
||||||
|
return imFriendShipService.getRelation(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/checkFriend")
|
||||||
|
public ResponseVO checkFriend(@RequestBody @Validated CheckFriendShipReq req, Integer appId){
|
||||||
|
req.setAppId(appId);
|
||||||
|
return imFriendShipService.checkFriendship(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/addBlack")
|
||||||
|
public ResponseVO addBlack(@RequestBody @Validated AddFriendShipBlackReq req, Integer appId){
|
||||||
|
req.setAppId(appId);
|
||||||
|
return imFriendShipService.addBlack(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/deleteBlack")
|
||||||
|
public ResponseVO deleteBlack(@RequestBody @Validated DeleteBlackReq req, Integer appId){
|
||||||
|
req.setAppId(appId);
|
||||||
|
return imFriendShipService.deleteBlack(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/checkBlck")
|
||||||
|
public ResponseVO checkBlck(@RequestBody @Validated CheckFriendShipReq req, Integer appId){
|
||||||
|
req.setAppId(appId);
|
||||||
|
return imFriendShipService.checkBlck(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
package com.lld.im.service.friendship.controller;
|
||||||
|
|
||||||
|
import com.lld.im.common.ResponseVO;
|
||||||
|
import com.lld.im.service.friendship.model.req.AddFriendShipGroupMemberReq;
|
||||||
|
import com.lld.im.service.friendship.model.req.AddFriendShipGroupReq;
|
||||||
|
import com.lld.im.service.friendship.model.req.DeleteFriendShipGroupMemberReq;
|
||||||
|
import com.lld.im.service.friendship.model.req.DeleteFriendShipGroupReq;
|
||||||
|
import com.lld.im.service.friendship.service.ImFriendShipGroupMemberService;
|
||||||
|
import com.lld.im.service.friendship.service.ImFriendShipGroupService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author: Chackylee
|
||||||
|
* @description:
|
||||||
|
**/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("v1/friendship/group")
|
||||||
|
public class ImFriendShipGroupController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
ImFriendShipGroupService imFriendShipGroupService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
ImFriendShipGroupMemberService imFriendShipGroupMemberService;
|
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping("/add")
|
||||||
|
public ResponseVO add(@RequestBody @Validated AddFriendShipGroupReq req, Integer appId) {
|
||||||
|
req.setAppId(appId);
|
||||||
|
return imFriendShipGroupService.addGroup(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/del")
|
||||||
|
public ResponseVO del(@RequestBody @Validated DeleteFriendShipGroupReq req, Integer appId) {
|
||||||
|
req.setAppId(appId);
|
||||||
|
return imFriendShipGroupService.deleteGroup(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/member/add")
|
||||||
|
public ResponseVO memberAdd(@RequestBody @Validated AddFriendShipGroupMemberReq req, Integer appId) {
|
||||||
|
req.setAppId(appId);
|
||||||
|
return imFriendShipGroupMemberService.addGroupMember(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/member/del")
|
||||||
|
public ResponseVO memberdel(@RequestBody @Validated DeleteFriendShipGroupMemberReq req, Integer appId) {
|
||||||
|
req.setAppId(appId);
|
||||||
|
return imFriendShipGroupMemberService.delGroupMember(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
package com.lld.im.service.friendship.controller;
|
||||||
|
|
||||||
|
import com.lld.im.common.ResponseVO;
|
||||||
|
import com.lld.im.service.friendship.model.req.ApproverFriendRequestReq;
|
||||||
|
import com.lld.im.service.friendship.model.req.GetFriendShipRequestReq;
|
||||||
|
import com.lld.im.service.friendship.model.req.ReadFriendShipRequestReq;
|
||||||
|
import com.lld.im.service.friendship.service.ImFriendShipRequestService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("v1/friendshipRequest")
|
||||||
|
public class ImFriendShipRequestController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
ImFriendShipRequestService imFriendShipRequestService;
|
||||||
|
|
||||||
|
@RequestMapping("/approveFriendRequest")
|
||||||
|
public ResponseVO approveFriendRequest(@RequestBody @Validated
|
||||||
|
ApproverFriendRequestReq req, Integer appId, String identifier){
|
||||||
|
req.setAppId(appId);
|
||||||
|
req.setOperater(identifier);
|
||||||
|
return imFriendShipRequestService.approverFriendRequest(req);
|
||||||
|
}
|
||||||
|
@RequestMapping("/getFriendRequest")
|
||||||
|
public ResponseVO getFriendRequest(@RequestBody @Validated GetFriendShipRequestReq req, Integer appId){
|
||||||
|
req.setAppId(appId);
|
||||||
|
return imFriendShipRequestService.getFriendRequest(req.getFromId(),req.getAppId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/readFriendShipRequestReq")
|
||||||
|
public ResponseVO readFriendShipRequestReq(@RequestBody @Validated ReadFriendShipRequestReq req, Integer appId){
|
||||||
|
req.setAppId(appId);
|
||||||
|
return imFriendShipRequestService.readFriendShipRequestReq(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
package com.lld.im.service.friendship.dao;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.github.jeffreyning.mybatisplus.anno.AutoMap;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author: Chackylee
|
||||||
|
* @description:
|
||||||
|
**/
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@TableName("im_friendship")
|
||||||
|
@AutoMap
|
||||||
|
public class ImFriendShipEntity {
|
||||||
|
|
||||||
|
@TableField(value = "app_id")
|
||||||
|
private Integer appId;
|
||||||
|
|
||||||
|
@TableField(value = "from_id")
|
||||||
|
private String fromId;
|
||||||
|
|
||||||
|
@TableField(value = "to_id")
|
||||||
|
private String toId;
|
||||||
|
/** 备注*/
|
||||||
|
private String remark;
|
||||||
|
/** 状态 1正常 2删除*/
|
||||||
|
private Integer status;
|
||||||
|
/** 状态 1正常 2拉黑*/
|
||||||
|
private Integer black;
|
||||||
|
// @TableField(updateStrategy = FieldStrategy.IGNORED)
|
||||||
|
private Long createTime;
|
||||||
|
/** 好友关系序列号*/
|
||||||
|
// @TableField(updateStrategy = FieldStrategy.IGNORED)
|
||||||
|
private Long friendSequence;
|
||||||
|
|
||||||
|
/** 黑名单关系序列号*/
|
||||||
|
private Long blackSequence;
|
||||||
|
/** 好友来源*/
|
||||||
|
// @TableField(updateStrategy = FieldStrategy.IGNORED)
|
||||||
|
private String addSource;
|
||||||
|
|
||||||
|
private String extra;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package com.lld.im.service.friendship.dao;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@TableName("im_friendship_group")
|
||||||
|
public class ImFriendShipGroupEntity {
|
||||||
|
|
||||||
|
@TableId(value = "group_id",type = IdType.AUTO)
|
||||||
|
private Long groupId;
|
||||||
|
|
||||||
|
private String fromId;
|
||||||
|
|
||||||
|
private Integer appId;
|
||||||
|
|
||||||
|
private String groupName;
|
||||||
|
/** 备注*/
|
||||||
|
private Long createTime;
|
||||||
|
|
||||||
|
/** 备注*/
|
||||||
|
private Long updateTime;
|
||||||
|
|
||||||
|
/** 序列号*/
|
||||||
|
private Long sequence;
|
||||||
|
|
||||||
|
private int delFlag;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package com.lld.im.service.friendship.dao;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@TableName("im_friendship_group_member")
|
||||||
|
public class ImFriendShipGroupMemberEntity {
|
||||||
|
|
||||||
|
@TableId(value = "group_id")
|
||||||
|
private Long groupId;
|
||||||
|
|
||||||
|
private String toId;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
package com.lld.im.service.friendship.dao;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@TableName("im_friendship_request")
|
||||||
|
public class ImFriendShipRequestEntity {
|
||||||
|
|
||||||
|
@TableId(type = IdType.AUTO)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
private Integer appId;
|
||||||
|
|
||||||
|
private String fromId;
|
||||||
|
|
||||||
|
private String toId;
|
||||||
|
/** 备注*/
|
||||||
|
// @TableField(updateStrategy = FieldStrategy.IGNORED)
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
//是否已读 1已读
|
||||||
|
private Integer readStatus;
|
||||||
|
|
||||||
|
/** 好友来源*/
|
||||||
|
// @TableField(updateStrategy = FieldStrategy.IGNORED)
|
||||||
|
private String addSource;
|
||||||
|
|
||||||
|
// @TableField(updateStrategy = FieldStrategy.IGNORED)
|
||||||
|
private String addWording;
|
||||||
|
|
||||||
|
//审批状态 1同意 2拒绝
|
||||||
|
private Integer approveStatus;
|
||||||
|
|
||||||
|
// @TableField(updateStrategy = FieldStrategy.IGNORED)
|
||||||
|
private Long createTime;
|
||||||
|
|
||||||
|
private Long updateTime;
|
||||||
|
|
||||||
|
/** 序列号*/
|
||||||
|
private Long sequence;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package com.lld.im.service.friendship.dao.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.lld.im.service.friendship.dao.ImFriendShipGroupEntity;
|
||||||
|
|
||||||
|
public interface ImFriendShipGroupMapper extends BaseMapper<ImFriendShipGroupEntity> {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package com.lld.im.service.friendship.dao.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.lld.im.service.friendship.dao.ImFriendShipGroupMemberEntity;
|
||||||
|
|
||||||
|
public interface ImFriendShipGroupMemberMapper extends BaseMapper<ImFriendShipGroupMemberEntity> {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,91 @@
|
|||||||
|
package com.lld.im.service.friendship.dao.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.lld.im.service.friendship.dao.ImFriendShipEntity;
|
||||||
|
import com.lld.im.service.friendship.model.req.CheckFriendShipReq;
|
||||||
|
import com.lld.im.service.friendship.model.resp.CheckFriendShipResp;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface ImFriendShipMapper extends BaseMapper<ImFriendShipEntity> {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Select("<script>"+
|
||||||
|
"select from_id as fromId , to_id as toId ,if(status = 1,1,0) as status from im_friendship where from_id = #{fromId} and to_id in " +
|
||||||
|
"<foreach collection='toIds' index='index' item='id' separator=',' close = ')' open='(' > " +
|
||||||
|
"#{id}" +
|
||||||
|
"</foreach>" +
|
||||||
|
"</script>")
|
||||||
|
public List<CheckFriendShipResp> checkFriendShip(CheckFriendShipReq req);
|
||||||
|
|
||||||
|
|
||||||
|
@Select("<script>" +
|
||||||
|
" select a.fromId,a.toId , ( \n" +
|
||||||
|
" case \n" +
|
||||||
|
" when a.status = 1 and b.status = 1 then 1 \n" +
|
||||||
|
" when a.status = 1 and b.status != 1 then 2 \n" +
|
||||||
|
" when a.status != 1 and b.status = 1 then 3 \n" +
|
||||||
|
" when a.status != 1 and b.status != 1 then 4 \n" +
|
||||||
|
" end \n" +
|
||||||
|
" ) \n " +
|
||||||
|
" as status from "+
|
||||||
|
" (select from_id AS fromId , to_id AS toId , if(status = 1,1,0) as status from im_friendship where app_id = #{appId} and from_id = #{fromId} AND to_id in " +
|
||||||
|
"<foreach collection='toIds' index='index' item='id' separator=',' close=')' open='('>" +
|
||||||
|
" #{id} " +
|
||||||
|
"</foreach>" +
|
||||||
|
" ) as a INNER join" +
|
||||||
|
" (select from_id AS fromId, to_id AS toId , if(status = 1,1,0) as status from im_friendship where app_id = #{appId} and to_id = #{fromId} AND from_id in " +
|
||||||
|
"<foreach collection='toIds' index='index' item='id' separator=',' close=')' open='('>" +
|
||||||
|
" #{id} " +
|
||||||
|
"</foreach>" +
|
||||||
|
" ) as b " +
|
||||||
|
" on a.fromId = b.toId AND b.fromId = a.toId "+
|
||||||
|
"</script>"
|
||||||
|
)
|
||||||
|
List<CheckFriendShipResp> checkFriendShipBoth(CheckFriendShipReq toId);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Select("<script>" +
|
||||||
|
" select from_id AS fromId, to_id AS toId , if(black = 1,1,0) as status from im_friendship where app_id = #{appId} and from_id = #{fromId} and to_id in " +
|
||||||
|
"<foreach collection='toIds' index='index' item='id' separator=',' close=')' open='('>" +
|
||||||
|
" #{id} " +
|
||||||
|
"</foreach>" +
|
||||||
|
"</script>"
|
||||||
|
)
|
||||||
|
List<CheckFriendShipResp> checkFriendShipBlack(CheckFriendShipReq req);
|
||||||
|
|
||||||
|
@Select("<script>" +
|
||||||
|
" select a.fromId,a.toId , ( \n" +
|
||||||
|
" case \n" +
|
||||||
|
" when a.black = 1 and b.black = 1 then 1 \n" +
|
||||||
|
" when a.black = 1 and b.black != 1 then 2 \n" +
|
||||||
|
" when a.black != 1 and b.black = 1 then 3 \n" +
|
||||||
|
" when a.black != 1 and b.black != 1 then 4 \n" +
|
||||||
|
" end \n" +
|
||||||
|
" ) \n " +
|
||||||
|
" as status from "+
|
||||||
|
" (select from_id AS fromId , to_id AS toId , if(black = 1,1,0) as black from im_friendship where app_id = #{appId} and from_id = #{fromId} AND to_id in " +
|
||||||
|
"<foreach collection='toIds' index='index' item='id' separator=',' close=')' open='('>" +
|
||||||
|
" #{id} " +
|
||||||
|
"</foreach>" +
|
||||||
|
" ) as a INNER join" +
|
||||||
|
" (select from_id AS fromId, to_id AS toId , if(black = 1,1,0) as black from im_friendship where app_id = #{appId} and to_id = #{fromId} AND from_id in " +
|
||||||
|
"<foreach collection='toIds' index='index' item='id' separator=',' close=')' open='('>" +
|
||||||
|
" #{id} " +
|
||||||
|
"</foreach>" +
|
||||||
|
" ) as b " +
|
||||||
|
" on a.fromId = b.toId AND b.fromId = a.toId "+
|
||||||
|
"</script>"
|
||||||
|
)
|
||||||
|
List<CheckFriendShipResp> checkFriendShipBlackBoth(CheckFriendShipReq toId);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package com.lld.im.service.friendship.dao.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.lld.im.service.friendship.dao.ImFriendShipRequestEntity;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface ImFriendShipRequestMapper extends BaseMapper<ImFriendShipRequestEntity> {
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package com.lld.im.service.friendship.model.req;
|
||||||
|
|
||||||
|
import com.lld.im.common.model.RequestBase;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class AddFriendReq extends RequestBase {
|
||||||
|
|
||||||
|
@NotBlank(message = "fromId不能为空")
|
||||||
|
private String fromId;
|
||||||
|
|
||||||
|
@NotNull(message = "toItem不能为空")
|
||||||
|
private FriendDto toItem;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.lld.im.service.friendship.model.req;
|
||||||
|
|
||||||
|
import com.lld.im.common.model.RequestBase;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class AddFriendShipBlackReq extends RequestBase {
|
||||||
|
|
||||||
|
@NotBlank(message = "用户id不能为空")
|
||||||
|
private String fromId;
|
||||||
|
|
||||||
|
private String toId;
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package com.lld.im.service.friendship.model.req;
|
||||||
|
|
||||||
|
import com.lld.im.common.model.RequestBase;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import javax.validation.constraints.NotEmpty;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class AddFriendShipGroupMemberReq extends RequestBase {
|
||||||
|
|
||||||
|
@NotBlank(message = "fromId不能为空")
|
||||||
|
private String fromId;
|
||||||
|
|
||||||
|
@NotBlank(message = "分组名称不能为空")
|
||||||
|
private String groupName;
|
||||||
|
|
||||||
|
@NotEmpty(message = "请选择用户")
|
||||||
|
private List<String> toIds;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package com.lld.im.service.friendship.model.req;
|
||||||
|
|
||||||
|
import com.lld.im.common.model.RequestBase;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class AddFriendShipGroupReq extends RequestBase {
|
||||||
|
|
||||||
|
@NotBlank(message = "fromId不能为空")
|
||||||
|
public String fromId;
|
||||||
|
|
||||||
|
@NotBlank(message = "分组名称不能为空")
|
||||||
|
private String groupName;
|
||||||
|
|
||||||
|
private List<String> toIds;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package com.lld.im.service.friendship.model.req;
|
||||||
|
|
||||||
|
import com.lld.im.common.model.RequestBase;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ApproverFriendRequestReq extends RequestBase {
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
//1同意 2拒绝
|
||||||
|
private Integer status;
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package com.lld.im.service.friendship.model.req;
|
||||||
|
|
||||||
|
import com.lld.im.common.model.RequestBase;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import javax.validation.constraints.NotEmpty;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description:
|
||||||
|
* @author: lld
|
||||||
|
* @version: 1.0
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class CheckFriendShipReq extends RequestBase {
|
||||||
|
|
||||||
|
@NotBlank(message = "fromId不能为空")
|
||||||
|
private String fromId;
|
||||||
|
|
||||||
|
@NotEmpty(message = "toIds不能为空")
|
||||||
|
private List<String> toIds;
|
||||||
|
|
||||||
|
@NotNull(message = "checkType不能为空")
|
||||||
|
private Integer checkType;
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package com.lld.im.service.friendship.model.req;
|
||||||
|
|
||||||
|
|
||||||
|
import com.lld.im.common.model.RequestBase;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class DeleteBlackReq extends RequestBase {
|
||||||
|
|
||||||
|
@NotBlank(message = "用户id不能为空")
|
||||||
|
private String fromId;
|
||||||
|
|
||||||
|
@NotBlank(message = "好友id不能为空")
|
||||||
|
private String toId;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package com.lld.im.service.friendship.model.req;
|
||||||
|
|
||||||
|
import com.lld.im.common.model.RequestBase;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class DeleteFriendReq extends RequestBase {
|
||||||
|
|
||||||
|
@NotBlank(message = "fromId不能为空")
|
||||||
|
private String fromId;
|
||||||
|
|
||||||
|
@NotBlank(message = "toId不能为空")
|
||||||
|
private String toId;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package com.lld.im.service.friendship.model.req;
|
||||||
|
|
||||||
|
import com.lld.im.common.model.RequestBase;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import javax.validation.constraints.NotEmpty;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author: Chackylee
|
||||||
|
* @description:
|
||||||
|
**/
|
||||||
|
@Data
|
||||||
|
public class DeleteFriendShipGroupMemberReq extends RequestBase {
|
||||||
|
|
||||||
|
@NotBlank(message = "fromId不能为空")
|
||||||
|
private String fromId;
|
||||||
|
|
||||||
|
@NotBlank(message = "分组名称不能为空")
|
||||||
|
private String groupName;
|
||||||
|
|
||||||
|
@NotEmpty(message = "请选择用户")
|
||||||
|
private List<String> toIds;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package com.lld.im.service.friendship.model.req;
|
||||||
|
|
||||||
|
import com.lld.im.common.model.RequestBase;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import javax.validation.constraints.NotEmpty;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author: Chackylee
|
||||||
|
* @description: 删除分组,同时删除分组下的成员
|
||||||
|
**/
|
||||||
|
@Data
|
||||||
|
public class DeleteFriendShipGroupReq extends RequestBase {
|
||||||
|
|
||||||
|
@NotBlank(message = "fromId不能为空")
|
||||||
|
private String fromId;
|
||||||
|
|
||||||
|
@NotEmpty(message = "分组名称不能为空")
|
||||||
|
private List<String> groupName;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package com.lld.im.service.friendship.model.req;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class FriendDto {
|
||||||
|
|
||||||
|
private String toId;
|
||||||
|
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
private String addSource;
|
||||||
|
|
||||||
|
private String extra;
|
||||||
|
|
||||||
|
private String addWording;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package com.lld.im.service.friendship.model.req;
|
||||||
|
|
||||||
|
import com.lld.im.common.model.RequestBase;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class GetAllFriendShipReq extends RequestBase {
|
||||||
|
|
||||||
|
@NotBlank(message = "用户id不能为空")
|
||||||
|
private String fromId;
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package com.lld.im.service.friendship.model.req;
|
||||||
|
|
||||||
|
import com.lld.im.common.model.RequestBase;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description:
|
||||||
|
* @author: lld
|
||||||
|
* @version: 1.0
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class GetFriendShipRequestReq extends RequestBase {
|
||||||
|
|
||||||
|
@NotBlank(message = "用户id不能为空")
|
||||||
|
private String fromId;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.lld.im.service.friendship.model.req;
|
||||||
|
|
||||||
|
import com.lld.im.common.model.RequestBase;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class GetRelationReq extends RequestBase {
|
||||||
|
@NotBlank(message = "fromId不能为空")
|
||||||
|
private String fromId;
|
||||||
|
|
||||||
|
@NotBlank(message = "toId不能为空")
|
||||||
|
private String toId;
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package com.lld.im.service.friendship.model.req;
|
||||||
|
|
||||||
|
import com.lld.im.common.enums.FriendShipStatusEnum;
|
||||||
|
import com.lld.im.common.model.RequestBase;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ImporFriendShipReq extends RequestBase {
|
||||||
|
|
||||||
|
@NotBlank(message = "fromId不能为空")
|
||||||
|
private String fromId;
|
||||||
|
|
||||||
|
private List<ImportFriendDto> friendItem;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class ImportFriendDto{
|
||||||
|
|
||||||
|
private String toId;
|
||||||
|
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
private String addSource;
|
||||||
|
|
||||||
|
private Integer status = FriendShipStatusEnum.FRIEND_STATUS_NO_FRIEND.getCode();
|
||||||
|
|
||||||
|
private Integer black = FriendShipStatusEnum.BLACK_STATUS_NORMAL.getCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package com.lld.im.service.friendship.model.req;
|
||||||
|
|
||||||
|
import com.lld.im.common.model.RequestBase;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ReadFriendShipRequestReq extends RequestBase {
|
||||||
|
|
||||||
|
@NotBlank(message = "用户id不能为空")
|
||||||
|
private String fromId;
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package com.lld.im.service.friendship.model.req;
|
||||||
|
|
||||||
|
import com.lld.im.common.model.RequestBase;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class UpdateFriendReq extends RequestBase {
|
||||||
|
|
||||||
|
@NotBlank(message = "fromId不能为空")
|
||||||
|
private String fromId;
|
||||||
|
|
||||||
|
@NotNull(message = "toItem不能为空")
|
||||||
|
private FriendDto toItem;
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package com.lld.im.service.friendship.model.resp;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class CheckFriendShipResp {
|
||||||
|
|
||||||
|
private String fromId;
|
||||||
|
|
||||||
|
private String toId;
|
||||||
|
|
||||||
|
|
||||||
|
//校验状态,根据双向校验和单向校验有不同的status
|
||||||
|
//单向校验:1 from添加了to,不确定to是否添加了from CheckResult_single_Type_AWithB;
|
||||||
|
// 0 from没有添加to,也不确定to有没有添加from CheckResult_single_Type_NoRelation
|
||||||
|
//双向校验 1 from添加了to,to也添加了from CheckResult_Type_BothWay
|
||||||
|
// 2 from添加了t0,to没有添加from CheckResult_Both_Type_AWithB
|
||||||
|
// 3 from没有添加to,to添加了from, CheckResult_Both_Type_BWithA
|
||||||
|
// 4 双方都没有添加 CheckResult_Both_Type_NoRelation
|
||||||
|
|
||||||
|
//单向校验黑名单:1 from没有拉黑to,不确定to是否拉黑了from CheckResult_singe_Type_AWithB;
|
||||||
|
// 0 from拉黑to,不确定to是佛拉黑from CheckResult_singe_Type_NoRelation
|
||||||
|
//双向校验黑名单 1 from没有拉黑to,to也没有拉黑from CheckResult_Type_BothWay
|
||||||
|
// 2 from没有拉黑to,to拉黑from CheckResult_Both_Type_AWithB
|
||||||
|
// 3 from拉黑了to,to没有拉黑from CheckResult_Both_Type_BWithA
|
||||||
|
// 4 双方都拉黑 CheckResult_Both_Type_NoRelation
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package com.lld.im.service.friendship.model.resp;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ImportFriendShipResp {
|
||||||
|
|
||||||
|
private List<String> successId;
|
||||||
|
|
||||||
|
private List<String> errorId;
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
package com.lld.im.service.friendship.service;
|
||||||
|
|
||||||
|
import com.lld.im.common.ResponseVO;
|
||||||
|
import com.lld.im.common.model.RequestBase;
|
||||||
|
import com.lld.im.service.friendship.model.req.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description:
|
||||||
|
* @author: lld
|
||||||
|
* @version: 1.0
|
||||||
|
*/
|
||||||
|
public interface ImFriendService {
|
||||||
|
|
||||||
|
public ResponseVO importFriendShip(ImporFriendShipReq req);
|
||||||
|
|
||||||
|
public ResponseVO addFriend(AddFriendReq req);
|
||||||
|
|
||||||
|
public ResponseVO updateFriend(UpdateFriendReq req);
|
||||||
|
|
||||||
|
public ResponseVO deleteFriend(DeleteFriendReq req);
|
||||||
|
|
||||||
|
public ResponseVO deleteAllFriend(DeleteFriendReq req);
|
||||||
|
|
||||||
|
public ResponseVO getAllFriendShip(GetAllFriendShipReq req);
|
||||||
|
|
||||||
|
public ResponseVO getRelation(GetRelationReq req);
|
||||||
|
|
||||||
|
public ResponseVO doAddFriend(RequestBase requestBase,String fromId, FriendDto dto, Integer appId);
|
||||||
|
|
||||||
|
public ResponseVO checkFriendship(CheckFriendShipReq req);
|
||||||
|
|
||||||
|
public ResponseVO addBlack(AddFriendShipBlackReq req);
|
||||||
|
|
||||||
|
public ResponseVO deleteBlack(DeleteBlackReq req);
|
||||||
|
|
||||||
|
public ResponseVO checkBlck(CheckFriendShipReq req);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package com.lld.im.service.friendship.service;
|
||||||
|
|
||||||
|
import com.lld.im.common.ResponseVO;
|
||||||
|
import com.lld.im.service.friendship.model.req.AddFriendShipGroupMemberReq;
|
||||||
|
import com.lld.im.service.friendship.model.req.DeleteFriendShipGroupMemberReq;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author: Chackylee
|
||||||
|
* @description:
|
||||||
|
**/
|
||||||
|
public interface ImFriendShipGroupMemberService {
|
||||||
|
|
||||||
|
public ResponseVO addGroupMember(AddFriendShipGroupMemberReq req);
|
||||||
|
|
||||||
|
public ResponseVO delGroupMember(DeleteFriendShipGroupMemberReq req);
|
||||||
|
|
||||||
|
public int doAddGroupMember(Long groupId, String toId);
|
||||||
|
|
||||||
|
public int clearGroupMember(Long groupId);
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package com.lld.im.service.friendship.service;
|
||||||
|
|
||||||
|
import com.lld.im.common.ResponseVO;
|
||||||
|
import com.lld.im.service.friendship.dao.ImFriendShipGroupEntity;
|
||||||
|
import com.lld.im.service.friendship.model.req.AddFriendShipGroupReq;
|
||||||
|
import com.lld.im.service.friendship.model.req.DeleteFriendShipGroupReq;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author: Chackylee
|
||||||
|
* @description:
|
||||||
|
**/
|
||||||
|
public interface ImFriendShipGroupService {
|
||||||
|
|
||||||
|
public ResponseVO addGroup(AddFriendShipGroupReq req);
|
||||||
|
|
||||||
|
public ResponseVO deleteGroup(DeleteFriendShipGroupReq req);
|
||||||
|
|
||||||
|
public ResponseVO<ImFriendShipGroupEntity> getGroup(String fromId, String groupName, Integer appId);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package com.lld.im.service.friendship.service;
|
||||||
|
|
||||||
|
import com.lld.im.common.ResponseVO;
|
||||||
|
import com.lld.im.service.friendship.model.req.ApproverFriendRequestReq;
|
||||||
|
import com.lld.im.service.friendship.model.req.FriendDto;
|
||||||
|
import com.lld.im.service.friendship.model.req.ReadFriendShipRequestReq;
|
||||||
|
|
||||||
|
|
||||||
|
public interface ImFriendShipRequestService {
|
||||||
|
|
||||||
|
public ResponseVO addFienshipRequest(String fromId, FriendDto dto, Integer appId);
|
||||||
|
|
||||||
|
public ResponseVO approverFriendRequest(ApproverFriendRequestReq req);
|
||||||
|
|
||||||
|
public ResponseVO readFriendShipRequestReq(ReadFriendShipRequestReq req);
|
||||||
|
|
||||||
|
public ResponseVO getFriendRequest(String fromId, Integer appId);
|
||||||
|
}
|
||||||
@@ -0,0 +1,439 @@
|
|||||||
|
package com.lld.im.service.friendship.service.impl;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||||
|
import com.lld.im.common.ResponseVO;
|
||||||
|
import com.lld.im.common.enums.AllowFriendTypeEnum;
|
||||||
|
import com.lld.im.common.enums.CheckFriendShipTypeEnum;
|
||||||
|
import com.lld.im.common.enums.FriendShipErrorCode;
|
||||||
|
import com.lld.im.common.enums.FriendShipStatusEnum;
|
||||||
|
import com.lld.im.common.exception.ApplicationException;
|
||||||
|
import com.lld.im.common.model.RequestBase;
|
||||||
|
import com.lld.im.service.friendship.dao.ImFriendShipEntity;
|
||||||
|
import com.lld.im.service.friendship.dao.mapper.ImFriendShipMapper;
|
||||||
|
import com.lld.im.service.friendship.model.req.*;
|
||||||
|
import com.lld.im.service.friendship.model.resp.CheckFriendShipResp;
|
||||||
|
import com.lld.im.service.friendship.model.resp.ImportFriendShipResp;
|
||||||
|
import com.lld.im.service.friendship.service.ImFriendService;
|
||||||
|
import com.lld.im.service.friendship.service.ImFriendShipRequestService;
|
||||||
|
import com.lld.im.service.user.dao.ImUserDataEntity;
|
||||||
|
import com.lld.im.service.user.service.ImUserService;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description:
|
||||||
|
* @author: lld
|
||||||
|
* @version: 1.0
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class ImFriendServiceImpl implements ImFriendService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
ImFriendShipMapper imFriendShipMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
ImUserService imUserService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
ImFriendService imFriendService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
ImFriendShipRequestService imFriendShipRequestService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResponseVO importFriendShip(ImporFriendShipReq req) {
|
||||||
|
|
||||||
|
if(req.getFriendItem().size() > 100){
|
||||||
|
return ResponseVO.errorResponse(FriendShipErrorCode.IMPORT_SIZE_BEYOND);
|
||||||
|
}
|
||||||
|
ImportFriendShipResp resp = new ImportFriendShipResp();
|
||||||
|
List<String> successId = new ArrayList<>();
|
||||||
|
List<String> errorId = new ArrayList<>();
|
||||||
|
|
||||||
|
for (ImporFriendShipReq.ImportFriendDto dto:
|
||||||
|
req.getFriendItem()) {
|
||||||
|
ImFriendShipEntity entity = new ImFriendShipEntity();
|
||||||
|
BeanUtils.copyProperties(dto,entity);
|
||||||
|
entity.setAppId(req.getAppId());
|
||||||
|
entity.setFromId(req.getFromId());
|
||||||
|
try {
|
||||||
|
int insert = imFriendShipMapper.insert(entity);
|
||||||
|
if(insert == 1){
|
||||||
|
successId.add(dto.getToId());
|
||||||
|
}else{
|
||||||
|
errorId.add(dto.getToId());
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
errorId.add(dto.getToId());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
resp.setErrorId(errorId);
|
||||||
|
resp.setSuccessId(successId);
|
||||||
|
|
||||||
|
return ResponseVO.successResponse(resp);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResponseVO addFriend(AddFriendReq req) {
|
||||||
|
|
||||||
|
ResponseVO<ImUserDataEntity> fromInfo = imUserService.getSingleUserInfo(req.getFromId(), req.getAppId());
|
||||||
|
if(!fromInfo.isOk()){
|
||||||
|
return fromInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
ResponseVO<ImUserDataEntity> toInfo = imUserService.getSingleUserInfo(req.getToItem().getToId(), req.getAppId());
|
||||||
|
if(!toInfo.isOk()){
|
||||||
|
return toInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
ImUserDataEntity data = toInfo.getData();
|
||||||
|
|
||||||
|
if(data.getFriendAllowType() != null && data.getFriendAllowType() == AllowFriendTypeEnum.NOT_NEED.getCode()){
|
||||||
|
return this.doAddFriend(req,req.getFromId(), req.getToItem(), req.getAppId());
|
||||||
|
}else{
|
||||||
|
QueryWrapper<ImFriendShipEntity> query = new QueryWrapper<>();
|
||||||
|
query.eq("app_id",req.getAppId());
|
||||||
|
query.eq("from_id",req.getFromId());
|
||||||
|
query.eq("to_id",req.getToItem().getToId());
|
||||||
|
ImFriendShipEntity fromItem = imFriendShipMapper.selectOne(query);
|
||||||
|
if(fromItem == null || fromItem.getStatus()
|
||||||
|
!= FriendShipStatusEnum.FRIEND_STATUS_NORMAL.getCode()){
|
||||||
|
//插入一条好友申请的数据
|
||||||
|
ResponseVO responseVO = imFriendShipRequestService.addFienshipRequest(req.getFromId(), req.getToItem(), req.getAppId());
|
||||||
|
if(!responseVO.isOk()){
|
||||||
|
return responseVO;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
return ResponseVO.errorResponse(FriendShipErrorCode.TO_IS_YOUR_FRIEND);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return ResponseVO.successResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResponseVO updateFriend(UpdateFriendReq req) {
|
||||||
|
|
||||||
|
ResponseVO<ImUserDataEntity> fromInfo = imUserService.getSingleUserInfo(req.getFromId(), req.getAppId());
|
||||||
|
if(!fromInfo.isOk()){
|
||||||
|
return fromInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
ResponseVO<ImUserDataEntity> toInfo = imUserService.getSingleUserInfo(req.getToItem().getToId(), req.getAppId());
|
||||||
|
if(!toInfo.isOk()){
|
||||||
|
return toInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
ResponseVO responseVO = this.doUpdate(req.getFromId(), req.getToItem(), req.getAppId());
|
||||||
|
return responseVO;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public ResponseVO doUpdate(String fromId, FriendDto dto,Integer appId){
|
||||||
|
|
||||||
|
|
||||||
|
UpdateWrapper<ImFriendShipEntity> updateWrapper = new UpdateWrapper<>();
|
||||||
|
updateWrapper.lambda().set(ImFriendShipEntity::getAddSource,dto.getAddSource())
|
||||||
|
.set(ImFriendShipEntity::getExtra,dto.getExtra())
|
||||||
|
.set(ImFriendShipEntity::getRemark,dto.getRemark())
|
||||||
|
.eq(ImFriendShipEntity::getAppId,appId)
|
||||||
|
.eq(ImFriendShipEntity::getToId,dto.getToId())
|
||||||
|
.eq(ImFriendShipEntity::getFromId,fromId);
|
||||||
|
|
||||||
|
int update = imFriendShipMapper.update(null, updateWrapper);
|
||||||
|
if(update == 1){
|
||||||
|
return ResponseVO.successResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
return ResponseVO.errorResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public ResponseVO doAddFriend(RequestBase requestBase,String fromId, FriendDto dto, Integer appId){
|
||||||
|
|
||||||
|
//A-B
|
||||||
|
//Friend表插入A 和 B 两条记录
|
||||||
|
//查询是否有记录存在,如果存在则判断状态,如果是已添加,则提示已添加,如果是未添加,则修改状态
|
||||||
|
|
||||||
|
QueryWrapper<ImFriendShipEntity> query = new QueryWrapper<>();
|
||||||
|
query.eq("app_id",appId);
|
||||||
|
query.eq("from_id",fromId);
|
||||||
|
query.eq("to_id",dto.getToId());
|
||||||
|
ImFriendShipEntity fromItem = imFriendShipMapper.selectOne(query);
|
||||||
|
if(fromItem == null){
|
||||||
|
//走添加逻辑。
|
||||||
|
fromItem = new ImFriendShipEntity();
|
||||||
|
fromItem.setAppId(appId);
|
||||||
|
fromItem.setFromId(fromId);
|
||||||
|
// entity.setToId(to);
|
||||||
|
BeanUtils.copyProperties(dto,fromItem);
|
||||||
|
fromItem.setStatus(FriendShipStatusEnum.FRIEND_STATUS_NORMAL.getCode());
|
||||||
|
fromItem.setCreateTime(System.currentTimeMillis());
|
||||||
|
int insert = imFriendShipMapper.insert(fromItem);
|
||||||
|
if(insert != 1){
|
||||||
|
return ResponseVO.errorResponse(FriendShipErrorCode.ADD_FRIEND_ERROR);
|
||||||
|
}
|
||||||
|
} else{
|
||||||
|
//如果存在则判断状态,如果是已添加,则提示已添加,如果是未添加,则修改状态
|
||||||
|
if(fromItem.getStatus() == FriendShipStatusEnum.FRIEND_STATUS_NORMAL.getCode()){
|
||||||
|
return ResponseVO.errorResponse(FriendShipErrorCode.TO_IS_YOUR_FRIEND);
|
||||||
|
} else{
|
||||||
|
ImFriendShipEntity update = new ImFriendShipEntity();
|
||||||
|
|
||||||
|
if(StringUtils.isNotBlank(dto.getAddSource())){
|
||||||
|
update.setAddSource(dto.getAddSource());
|
||||||
|
}
|
||||||
|
|
||||||
|
if(StringUtils.isNotBlank(dto.getRemark())){
|
||||||
|
update.setRemark(dto.getRemark());
|
||||||
|
}
|
||||||
|
|
||||||
|
if(StringUtils.isNotBlank(dto.getExtra())){
|
||||||
|
update.setExtra(dto.getExtra());
|
||||||
|
}
|
||||||
|
update.setStatus(FriendShipStatusEnum.FRIEND_STATUS_NORMAL.getCode());
|
||||||
|
|
||||||
|
int result = imFriendShipMapper.update(update, query);
|
||||||
|
if(result != 1){
|
||||||
|
return ResponseVO.errorResponse(FriendShipErrorCode.ADD_FRIEND_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
QueryWrapper<ImFriendShipEntity> toQuery = new QueryWrapper<>();
|
||||||
|
toQuery.eq("app_id",appId);
|
||||||
|
toQuery.eq("from_id",dto.getToId());
|
||||||
|
toQuery.eq("to_id",fromId);
|
||||||
|
ImFriendShipEntity toItem = imFriendShipMapper.selectOne(toQuery);
|
||||||
|
if(toItem == null){
|
||||||
|
toItem = new ImFriendShipEntity();
|
||||||
|
toItem.setAppId(appId);
|
||||||
|
toItem.setFromId(dto.getToId());
|
||||||
|
BeanUtils.copyProperties(dto,toItem);
|
||||||
|
toItem.setToId(fromId);
|
||||||
|
toItem.setStatus(FriendShipStatusEnum.FRIEND_STATUS_NORMAL.getCode());
|
||||||
|
toItem.setCreateTime(System.currentTimeMillis());
|
||||||
|
// toItem.setBlack(FriendShipStatusEnum.BLACK_STATUS_NORMAL.getCode());
|
||||||
|
int insert = imFriendShipMapper.insert(toItem);
|
||||||
|
}else{
|
||||||
|
if(FriendShipStatusEnum.FRIEND_STATUS_NORMAL.getCode() !=
|
||||||
|
toItem.getStatus()){
|
||||||
|
ImFriendShipEntity update = new ImFriendShipEntity();
|
||||||
|
update.setStatus(FriendShipStatusEnum.FRIEND_STATUS_NORMAL.getCode());
|
||||||
|
imFriendShipMapper.update(update,toQuery);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ResponseVO.successResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResponseVO deleteFriend(DeleteFriendReq req) {
|
||||||
|
|
||||||
|
QueryWrapper<ImFriendShipEntity> query = new QueryWrapper<>();
|
||||||
|
query.eq("app_id",req.getAppId());
|
||||||
|
query.eq("from_id",req.getFromId());
|
||||||
|
query.eq("to_id",req.getToId());
|
||||||
|
ImFriendShipEntity fromItem = imFriendShipMapper.selectOne(query);
|
||||||
|
if(fromItem == null){
|
||||||
|
return ResponseVO.errorResponse(FriendShipErrorCode.TO_IS_NOT_YOUR_FRIEND);
|
||||||
|
}else{
|
||||||
|
if(fromItem.getStatus() != null && fromItem.getStatus() == FriendShipStatusEnum.FRIEND_STATUS_NORMAL.getCode()){
|
||||||
|
ImFriendShipEntity update = new ImFriendShipEntity();
|
||||||
|
update.setStatus(FriendShipStatusEnum.FRIEND_STATUS_DELETE.getCode());
|
||||||
|
imFriendShipMapper.update(update,query);
|
||||||
|
|
||||||
|
}else{
|
||||||
|
return ResponseVO.errorResponse(FriendShipErrorCode.FRIEND_IS_DELETED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ResponseVO.successResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResponseVO deleteAllFriend(DeleteFriendReq req) {
|
||||||
|
QueryWrapper<ImFriendShipEntity> query = new QueryWrapper<>();
|
||||||
|
query.eq("app_id",req.getAppId());
|
||||||
|
query.eq("from_id",req.getFromId());
|
||||||
|
query.eq("status",FriendShipStatusEnum.FRIEND_STATUS_NORMAL.getCode());
|
||||||
|
|
||||||
|
ImFriendShipEntity update = new ImFriendShipEntity();
|
||||||
|
update.setStatus(FriendShipStatusEnum.FRIEND_STATUS_DELETE.getCode());
|
||||||
|
imFriendShipMapper.update(update,query);
|
||||||
|
return ResponseVO.successResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResponseVO getAllFriendShip(GetAllFriendShipReq req) {
|
||||||
|
QueryWrapper<ImFriendShipEntity> query = new QueryWrapper<>();
|
||||||
|
query.eq("app_id",req.getAppId());
|
||||||
|
query.eq("from_id",req.getFromId());
|
||||||
|
return ResponseVO.successResponse(imFriendShipMapper.selectList(query));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResponseVO getRelation(GetRelationReq req) {
|
||||||
|
|
||||||
|
QueryWrapper<ImFriendShipEntity> query = new QueryWrapper<>();
|
||||||
|
query.eq("app_id",req.getAppId());
|
||||||
|
query.eq("from_id",req.getFromId());
|
||||||
|
query.eq("to_id",req.getToId());
|
||||||
|
|
||||||
|
ImFriendShipEntity entity = imFriendShipMapper.selectOne(query);
|
||||||
|
if(entity == null){
|
||||||
|
return ResponseVO.errorResponse(FriendShipErrorCode.REPEATSHIP_IS_NOT_EXIST);
|
||||||
|
}
|
||||||
|
return ResponseVO.successResponse(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResponseVO checkBlck(CheckFriendShipReq req) {
|
||||||
|
|
||||||
|
Map<String, Integer> toIdMap
|
||||||
|
= req.getToIds().stream().collect(Collectors
|
||||||
|
.toMap(Function.identity(), s -> 0));
|
||||||
|
List<CheckFriendShipResp> result = new ArrayList<>();
|
||||||
|
if (req.getCheckType() == CheckFriendShipTypeEnum.SINGLE.getType()) {
|
||||||
|
result = imFriendShipMapper.checkFriendShipBlack(req);
|
||||||
|
} else {
|
||||||
|
result = imFriendShipMapper.checkFriendShipBlackBoth(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, Integer> collect = result.stream()
|
||||||
|
.collect(Collectors
|
||||||
|
.toMap(CheckFriendShipResp::getToId,
|
||||||
|
CheckFriendShipResp::getStatus));
|
||||||
|
for (String toId:
|
||||||
|
toIdMap.keySet()) {
|
||||||
|
if(!collect.containsKey(toId)){
|
||||||
|
CheckFriendShipResp checkFriendShipResp = new CheckFriendShipResp();
|
||||||
|
checkFriendShipResp.setToId(toId);
|
||||||
|
checkFriendShipResp.setFromId(req.getFromId());
|
||||||
|
checkFriendShipResp.setStatus(toIdMap.get(toId));
|
||||||
|
result.add(checkFriendShipResp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ResponseVO.successResponse(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResponseVO addBlack(AddFriendShipBlackReq req) {
|
||||||
|
|
||||||
|
ResponseVO<ImUserDataEntity> fromInfo = imUserService.getSingleUserInfo(req.getFromId(), req.getAppId());
|
||||||
|
if(!fromInfo.isOk()){
|
||||||
|
return fromInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
ResponseVO<ImUserDataEntity> toInfo = imUserService.getSingleUserInfo(req.getToId(), req.getAppId());
|
||||||
|
if(!toInfo.isOk()){
|
||||||
|
return toInfo;
|
||||||
|
}
|
||||||
|
QueryWrapper<ImFriendShipEntity> query = new QueryWrapper<>();
|
||||||
|
query.eq("app_id",req.getAppId());
|
||||||
|
query.eq("from_id",req.getFromId());
|
||||||
|
query.eq("to_id",req.getToId());
|
||||||
|
|
||||||
|
ImFriendShipEntity fromItem = imFriendShipMapper.selectOne(query);
|
||||||
|
if(fromItem == null){
|
||||||
|
//走添加逻辑。
|
||||||
|
fromItem = new ImFriendShipEntity();
|
||||||
|
fromItem.setFromId(req.getFromId());
|
||||||
|
fromItem.setToId(req.getToId());
|
||||||
|
fromItem.setAppId(req.getAppId());
|
||||||
|
fromItem.setBlack(FriendShipStatusEnum.BLACK_STATUS_BLACKED.getCode());
|
||||||
|
fromItem.setCreateTime(System.currentTimeMillis());
|
||||||
|
int insert = imFriendShipMapper.insert(fromItem);
|
||||||
|
if(insert != 1){
|
||||||
|
return ResponseVO.errorResponse(FriendShipErrorCode.ADD_FRIEND_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else{
|
||||||
|
//如果存在则判断状态,如果是拉黑,则提示已拉黑,如果是未拉黑,则修改状态
|
||||||
|
if(fromItem.getBlack() != null && fromItem.getBlack() == FriendShipStatusEnum.BLACK_STATUS_BLACKED.getCode()){
|
||||||
|
return ResponseVO.errorResponse(FriendShipErrorCode.FRIEND_IS_BLACK);
|
||||||
|
} else {
|
||||||
|
ImFriendShipEntity update = new ImFriendShipEntity();
|
||||||
|
update.setBlack(FriendShipStatusEnum.BLACK_STATUS_BLACKED.getCode());
|
||||||
|
int result = imFriendShipMapper.update(update, query);
|
||||||
|
if(result != 1){
|
||||||
|
return ResponseVO.errorResponse(FriendShipErrorCode.ADD_BLACK_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ResponseVO.successResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResponseVO deleteBlack(DeleteBlackReq req) {
|
||||||
|
QueryWrapper queryFrom = new QueryWrapper<>()
|
||||||
|
.eq("from_id", req.getFromId())
|
||||||
|
.eq("app_id", req.getAppId())
|
||||||
|
.eq("to_id", req.getToId());
|
||||||
|
ImFriendShipEntity fromItem = imFriendShipMapper.selectOne(queryFrom);
|
||||||
|
if (fromItem.getBlack() != null && fromItem.getBlack() == FriendShipStatusEnum.BLACK_STATUS_NORMAL.getCode()) {
|
||||||
|
throw new ApplicationException(FriendShipErrorCode.FRIEND_IS_NOT_YOUR_BLACK);
|
||||||
|
}
|
||||||
|
|
||||||
|
ImFriendShipEntity update = new ImFriendShipEntity();
|
||||||
|
update.setBlack(FriendShipStatusEnum.BLACK_STATUS_NORMAL.getCode());
|
||||||
|
int update1 = imFriendShipMapper.update(update, queryFrom);
|
||||||
|
if(update1 == 1){
|
||||||
|
return ResponseVO.successResponse();
|
||||||
|
}
|
||||||
|
return ResponseVO.errorResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResponseVO checkFriendship(CheckFriendShipReq req) {
|
||||||
|
|
||||||
|
Map<String, Integer> result
|
||||||
|
= req.getToIds().stream()
|
||||||
|
.collect(Collectors.toMap(Function.identity(), s -> 0));
|
||||||
|
|
||||||
|
List<CheckFriendShipResp> resp = new ArrayList<>();
|
||||||
|
|
||||||
|
if(req.getCheckType() == CheckFriendShipTypeEnum.SINGLE.getType()){
|
||||||
|
resp =imFriendShipMapper.checkFriendShip(req);
|
||||||
|
}else {
|
||||||
|
resp =imFriendShipMapper.checkFriendShipBoth(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, Integer> collect = resp.stream()
|
||||||
|
.collect(Collectors.toMap(CheckFriendShipResp::getToId
|
||||||
|
, CheckFriendShipResp::getStatus));
|
||||||
|
|
||||||
|
for (String toId : result.keySet()){
|
||||||
|
if(!collect.containsKey(toId)){
|
||||||
|
CheckFriendShipResp checkFriendShipResp = new CheckFriendShipResp();
|
||||||
|
checkFriendShipResp.setFromId(req.getFromId());
|
||||||
|
checkFriendShipResp.setToId(toId);
|
||||||
|
checkFriendShipResp.setStatus(result.get(toId));
|
||||||
|
resp.add(checkFriendShipResp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ResponseVO.successResponse(resp);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,122 @@
|
|||||||
|
package com.lld.im.service.friendship.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.lld.im.common.ResponseVO;
|
||||||
|
import com.lld.im.service.friendship.dao.ImFriendShipGroupEntity;
|
||||||
|
import com.lld.im.service.friendship.dao.ImFriendShipGroupMemberEntity;
|
||||||
|
import com.lld.im.service.friendship.dao.mapper.ImFriendShipGroupMemberMapper;
|
||||||
|
import com.lld.im.service.friendship.model.req.AddFriendShipGroupMemberReq;
|
||||||
|
import com.lld.im.service.friendship.model.req.DeleteFriendShipGroupMemberReq;
|
||||||
|
import com.lld.im.service.friendship.service.ImFriendShipGroupMemberService;
|
||||||
|
import com.lld.im.service.friendship.service.ImFriendShipGroupService;
|
||||||
|
import com.lld.im.service.user.dao.ImUserDataEntity;
|
||||||
|
import com.lld.im.service.user.service.ImUserService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author: Chackylee
|
||||||
|
* @description:
|
||||||
|
**/
|
||||||
|
@Service
|
||||||
|
public class ImFriendShipGroupMemberServiceImpl
|
||||||
|
implements ImFriendShipGroupMemberService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
ImFriendShipGroupMemberMapper imFriendShipGroupMemberMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
ImFriendShipGroupService imFriendShipGroupService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
ImUserService imUserService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
ImFriendShipGroupMemberService thisService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public ResponseVO addGroupMember(AddFriendShipGroupMemberReq req) {
|
||||||
|
|
||||||
|
ResponseVO<ImFriendShipGroupEntity> group = imFriendShipGroupService
|
||||||
|
.getGroup(req.getFromId(),req.getGroupName(),req.getAppId());
|
||||||
|
if(!group.isOk()){
|
||||||
|
return group;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> successId = new ArrayList<>();
|
||||||
|
for (String toId : req.getToIds()) {
|
||||||
|
ResponseVO<ImUserDataEntity> singleUserInfo = imUserService.getSingleUserInfo(toId, req.getAppId());
|
||||||
|
if(singleUserInfo.isOk()){
|
||||||
|
int i = thisService.doAddGroupMember(group.getData().getGroupId(), toId);
|
||||||
|
if(i == 1){
|
||||||
|
successId.add(toId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ResponseVO.successResponse(successId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResponseVO delGroupMember(DeleteFriendShipGroupMemberReq req) {
|
||||||
|
ResponseVO<ImFriendShipGroupEntity> group = imFriendShipGroupService
|
||||||
|
.getGroup(req.getFromId(),req.getGroupName(),req.getAppId());
|
||||||
|
if(!group.isOk()){
|
||||||
|
return group;
|
||||||
|
}
|
||||||
|
|
||||||
|
ArrayList list = new ArrayList();
|
||||||
|
for (String toId : req.getToIds()) {
|
||||||
|
ResponseVO<ImUserDataEntity> singleUserInfo = imUserService.getSingleUserInfo(toId, req.getAppId());
|
||||||
|
if(singleUserInfo.isOk()){
|
||||||
|
int i = deleteGroupMember(group.getData().getGroupId(), toId);
|
||||||
|
if(i == 1){
|
||||||
|
list.add(toId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ResponseVO.successResponse(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int doAddGroupMember(Long groupId, String toId) {
|
||||||
|
ImFriendShipGroupMemberEntity imFriendShipGroupMemberEntity = new ImFriendShipGroupMemberEntity();
|
||||||
|
imFriendShipGroupMemberEntity.setGroupId(groupId);
|
||||||
|
imFriendShipGroupMemberEntity.setToId(toId);
|
||||||
|
try {
|
||||||
|
int insert = imFriendShipGroupMemberMapper.insert(imFriendShipGroupMemberEntity);
|
||||||
|
return insert;
|
||||||
|
}catch (Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int deleteGroupMember(Long groupId, String toId) {
|
||||||
|
QueryWrapper<ImFriendShipGroupMemberEntity> queryWrapper = new QueryWrapper<>();
|
||||||
|
queryWrapper.eq("group_id",groupId);
|
||||||
|
queryWrapper.eq("to_id",toId);
|
||||||
|
|
||||||
|
try {
|
||||||
|
int delete = imFriendShipGroupMemberMapper.delete(queryWrapper);
|
||||||
|
// int insert = imFriendShipGroupMemberMapper.insert(imFriendShipGroupMemberEntity);
|
||||||
|
return delete;
|
||||||
|
}catch (Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int clearGroupMember(Long groupId) {
|
||||||
|
QueryWrapper<ImFriendShipGroupMemberEntity> query = new QueryWrapper<>();
|
||||||
|
query.eq("group_id",groupId);
|
||||||
|
int delete = imFriendShipGroupMemberMapper.delete(query);
|
||||||
|
return delete;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,119 @@
|
|||||||
|
package com.lld.im.service.friendship.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.lld.im.common.ResponseVO;
|
||||||
|
import com.lld.im.common.enums.DelFlagEnum;
|
||||||
|
import com.lld.im.common.enums.FriendShipErrorCode;
|
||||||
|
import com.lld.im.service.friendship.dao.ImFriendShipGroupEntity;
|
||||||
|
import com.lld.im.service.friendship.dao.mapper.ImFriendShipGroupMapper;
|
||||||
|
import com.lld.im.service.friendship.model.req.AddFriendShipGroupMemberReq;
|
||||||
|
import com.lld.im.service.friendship.model.req.AddFriendShipGroupReq;
|
||||||
|
import com.lld.im.service.friendship.model.req.DeleteFriendShipGroupReq;
|
||||||
|
import com.lld.im.service.friendship.service.ImFriendShipGroupMemberService;
|
||||||
|
import com.lld.im.service.friendship.service.ImFriendShipGroupService;
|
||||||
|
import com.lld.im.service.user.service.ImUserService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.dao.DuplicateKeyException;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class ImFriendShipGroupServiceImpl implements ImFriendShipGroupService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
ImFriendShipGroupMapper imFriendShipGroupMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
ImFriendShipGroupMemberService imFriendShipGroupMemberService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
ImUserService imUserService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public ResponseVO addGroup(AddFriendShipGroupReq req) {
|
||||||
|
|
||||||
|
QueryWrapper<ImFriendShipGroupEntity> query = new QueryWrapper<>();
|
||||||
|
query.eq("group_name", req.getGroupName());
|
||||||
|
query.eq("app_id", req.getAppId());
|
||||||
|
query.eq("from_id", req.getFromId());
|
||||||
|
query.eq("del_flag", DelFlagEnum.NORMAL.getCode());
|
||||||
|
|
||||||
|
ImFriendShipGroupEntity entity = imFriendShipGroupMapper.selectOne(query);
|
||||||
|
|
||||||
|
if (entity != null) {
|
||||||
|
return ResponseVO.errorResponse(FriendShipErrorCode.FRIEND_SHIP_GROUP_IS_EXIST);
|
||||||
|
}
|
||||||
|
|
||||||
|
//写入db
|
||||||
|
ImFriendShipGroupEntity insert = new ImFriendShipGroupEntity();
|
||||||
|
insert.setAppId(req.getAppId());
|
||||||
|
insert.setCreateTime(System.currentTimeMillis());
|
||||||
|
insert.setDelFlag(DelFlagEnum.NORMAL.getCode());
|
||||||
|
insert.setGroupName(req.getGroupName());
|
||||||
|
insert.setFromId(req.getFromId());
|
||||||
|
try {
|
||||||
|
int insert1 = imFriendShipGroupMapper.insert(insert);
|
||||||
|
|
||||||
|
if (insert1 != 1) {
|
||||||
|
return ResponseVO.errorResponse(FriendShipErrorCode.FRIEND_SHIP_GROUP_CREATE_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (insert1 == 1 && CollectionUtil.isNotEmpty(req.getToIds())) {
|
||||||
|
AddFriendShipGroupMemberReq addFriendShipGroupMemberReq = new AddFriendShipGroupMemberReq();
|
||||||
|
addFriendShipGroupMemberReq.setFromId(req.getFromId());
|
||||||
|
addFriendShipGroupMemberReq.setGroupName(req.getGroupName());
|
||||||
|
addFriendShipGroupMemberReq.setToIds(req.getToIds());
|
||||||
|
addFriendShipGroupMemberReq.setAppId(req.getAppId());
|
||||||
|
imFriendShipGroupMemberService.addGroupMember(addFriendShipGroupMemberReq);
|
||||||
|
return ResponseVO.successResponse();
|
||||||
|
}
|
||||||
|
} catch (DuplicateKeyException e) {
|
||||||
|
e.getStackTrace();
|
||||||
|
return ResponseVO.errorResponse(FriendShipErrorCode.FRIEND_SHIP_GROUP_IS_EXIST);
|
||||||
|
}
|
||||||
|
return ResponseVO.successResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public ResponseVO deleteGroup(DeleteFriendShipGroupReq req) {
|
||||||
|
|
||||||
|
for (String groupName : req.getGroupName()) {
|
||||||
|
QueryWrapper<ImFriendShipGroupEntity> query = new QueryWrapper<>();
|
||||||
|
query.eq("group_name", groupName);
|
||||||
|
query.eq("app_id", req.getAppId());
|
||||||
|
query.eq("from_id", req.getFromId());
|
||||||
|
query.eq("del_flag", DelFlagEnum.NORMAL.getCode());
|
||||||
|
|
||||||
|
ImFriendShipGroupEntity entity = imFriendShipGroupMapper.selectOne(query);
|
||||||
|
|
||||||
|
if (entity != null) {
|
||||||
|
ImFriendShipGroupEntity update = new ImFriendShipGroupEntity();
|
||||||
|
update.setGroupId(entity.getGroupId());
|
||||||
|
update.setDelFlag(DelFlagEnum.DELETE.getCode());
|
||||||
|
imFriendShipGroupMapper.updateById(update);
|
||||||
|
imFriendShipGroupMemberService.clearGroupMember(entity.getGroupId());
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ResponseVO.successResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResponseVO getGroup(String fromId, String groupName, Integer appId) {
|
||||||
|
QueryWrapper<ImFriendShipGroupEntity> query = new QueryWrapper<>();
|
||||||
|
query.eq("group_name", groupName);
|
||||||
|
query.eq("app_id", appId);
|
||||||
|
query.eq("from_id", fromId);
|
||||||
|
query.eq("del_flag", DelFlagEnum.NORMAL.getCode());
|
||||||
|
|
||||||
|
ImFriendShipGroupEntity entity = imFriendShipGroupMapper.selectOne(query);
|
||||||
|
if (entity == null) {
|
||||||
|
return ResponseVO.errorResponse(FriendShipErrorCode.FRIEND_SHIP_GROUP_IS_NOT_EXIST);
|
||||||
|
}
|
||||||
|
return ResponseVO.successResponse(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,140 @@
|
|||||||
|
package com.lld.im.service.friendship.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.lld.im.common.ResponseVO;
|
||||||
|
import com.lld.im.common.enums.ApproverFriendRequestStatusEnum;
|
||||||
|
import com.lld.im.common.enums.FriendShipErrorCode;
|
||||||
|
import com.lld.im.common.exception.ApplicationException;
|
||||||
|
import com.lld.im.service.friendship.dao.ImFriendShipRequestEntity;
|
||||||
|
import com.lld.im.service.friendship.dao.mapper.ImFriendShipRequestMapper;
|
||||||
|
import com.lld.im.service.friendship.model.req.ApproverFriendRequestReq;
|
||||||
|
import com.lld.im.service.friendship.model.req.FriendDto;
|
||||||
|
import com.lld.im.service.friendship.model.req.ReadFriendShipRequestReq;
|
||||||
|
import com.lld.im.service.friendship.service.ImFriendService;
|
||||||
|
import com.lld.im.service.friendship.service.ImFriendShipRequestService;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class ImFriendShipRequestServiceImpl implements ImFriendShipRequestService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
ImFriendShipRequestMapper imFriendShipRequestMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
ImFriendService imFriendShipService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResponseVO getFriendRequest(String fromId, Integer appId) {
|
||||||
|
|
||||||
|
QueryWrapper<ImFriendShipRequestEntity> query = new QueryWrapper();
|
||||||
|
query.eq("app_id", appId);
|
||||||
|
query.eq("to_id", fromId);
|
||||||
|
|
||||||
|
List<ImFriendShipRequestEntity> requestList = imFriendShipRequestMapper.selectList(query);
|
||||||
|
|
||||||
|
return ResponseVO.successResponse(requestList);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//A + B
|
||||||
|
@Override
|
||||||
|
public ResponseVO addFienshipRequest(String fromId, FriendDto dto, Integer appId) {
|
||||||
|
|
||||||
|
QueryWrapper<ImFriendShipRequestEntity> queryWrapper = new QueryWrapper<>();
|
||||||
|
queryWrapper.eq("app_id",appId);
|
||||||
|
queryWrapper.eq("from_id",fromId);
|
||||||
|
queryWrapper.eq("to_id",dto.getToId());
|
||||||
|
ImFriendShipRequestEntity request = imFriendShipRequestMapper.selectOne(queryWrapper);
|
||||||
|
|
||||||
|
if(request == null){
|
||||||
|
request = new ImFriendShipRequestEntity();
|
||||||
|
request.setAddSource(dto.getAddSource());
|
||||||
|
request.setAddWording(dto.getAddWording());
|
||||||
|
request.setAppId(appId);
|
||||||
|
request.setFromId(fromId);
|
||||||
|
request.setToId(dto.getToId());
|
||||||
|
request.setReadStatus(0);
|
||||||
|
request.setApproveStatus(0);
|
||||||
|
request.setRemark(dto.getRemark());
|
||||||
|
request.setCreateTime(System.currentTimeMillis());
|
||||||
|
imFriendShipRequestMapper.insert(request);
|
||||||
|
|
||||||
|
}else {
|
||||||
|
//修改记录内容 和更新时间
|
||||||
|
if(StringUtils.isNotBlank(dto.getAddSource())){
|
||||||
|
request.setAddWording(dto.getAddWording());
|
||||||
|
}
|
||||||
|
if(StringUtils.isNotBlank(dto.getRemark())){
|
||||||
|
request.setRemark(dto.getRemark());
|
||||||
|
}
|
||||||
|
if(StringUtils.isNotBlank(dto.getAddWording())){
|
||||||
|
request.setAddWording(dto.getAddWording());
|
||||||
|
}
|
||||||
|
request.setApproveStatus(0);
|
||||||
|
request.setReadStatus(0);
|
||||||
|
imFriendShipRequestMapper.updateById(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ResponseVO.successResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public ResponseVO approverFriendRequest(ApproverFriendRequestReq req) {
|
||||||
|
|
||||||
|
ImFriendShipRequestEntity imFriendShipRequestEntity = imFriendShipRequestMapper.selectById(req.getId());
|
||||||
|
if(imFriendShipRequestEntity == null){
|
||||||
|
throw new ApplicationException(FriendShipErrorCode.FRIEND_REQUEST_IS_NOT_EXIST);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!req.getOperater().equals(imFriendShipRequestEntity.getToId())){
|
||||||
|
//只能审批发给自己的好友请求
|
||||||
|
throw new ApplicationException(FriendShipErrorCode.NOT_APPROVER_OTHER_MAN_REQUEST);
|
||||||
|
}
|
||||||
|
|
||||||
|
ImFriendShipRequestEntity update = new ImFriendShipRequestEntity();
|
||||||
|
update.setApproveStatus(req.getStatus());
|
||||||
|
update.setUpdateTime(System.currentTimeMillis());
|
||||||
|
update.setId(req.getId());
|
||||||
|
imFriendShipRequestMapper.updateById(update);
|
||||||
|
|
||||||
|
if(ApproverFriendRequestStatusEnum.AGREE.getCode() == req.getStatus()){
|
||||||
|
//同意 ===> 去执行添加好友逻辑
|
||||||
|
FriendDto dto = new FriendDto();
|
||||||
|
dto.setAddSource(imFriendShipRequestEntity.getAddSource());
|
||||||
|
dto.setAddWording(imFriendShipRequestEntity.getAddWording());
|
||||||
|
dto.setRemark(imFriendShipRequestEntity.getRemark());
|
||||||
|
dto.setToId(imFriendShipRequestEntity.getToId());
|
||||||
|
ResponseVO responseVO = imFriendShipService.doAddFriend(req,imFriendShipRequestEntity.getFromId(), dto,req.getAppId());
|
||||||
|
// if(!responseVO.isOk()){
|
||||||
|
//// TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||||
|
// return responseVO;
|
||||||
|
// }
|
||||||
|
if(!responseVO.isOk() && responseVO.getCode() != FriendShipErrorCode.TO_IS_YOUR_FRIEND.getCode()){
|
||||||
|
return responseVO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ResponseVO.successResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResponseVO readFriendShipRequestReq(ReadFriendShipRequestReq req) {
|
||||||
|
QueryWrapper<ImFriendShipRequestEntity> query = new QueryWrapper<>();
|
||||||
|
query.eq("app_id", req.getAppId());
|
||||||
|
query.eq("to_id", req.getFromId());
|
||||||
|
|
||||||
|
ImFriendShipRequestEntity update = new ImFriendShipRequestEntity();
|
||||||
|
update.setReadStatus(1);
|
||||||
|
imFriendShipRequestMapper.update(update, query);
|
||||||
|
|
||||||
|
return ResponseVO.successResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
package com.lld.im.service.group.controller;
|
||||||
|
|
||||||
|
import com.lld.im.common.ResponseVO;
|
||||||
|
import com.lld.im.service.group.model.req.*;
|
||||||
|
import com.lld.im.service.group.service.ImGroupService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description:
|
||||||
|
* @author: lld
|
||||||
|
* @version: 1.0
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("v1/group")
|
||||||
|
public class ImGroupController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
ImGroupService groupService;
|
||||||
|
|
||||||
|
@RequestMapping("/importGroup")
|
||||||
|
public ResponseVO importGroup(@RequestBody @Validated ImportGroupReq req, Integer appId, String identifier) {
|
||||||
|
req.setAppId(appId);
|
||||||
|
req.setOperater(identifier);
|
||||||
|
return groupService.importGroup(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/createGroup")
|
||||||
|
public ResponseVO createGroup(@RequestBody @Validated CreateGroupReq req, Integer appId, String identifier) {
|
||||||
|
req.setAppId(appId);
|
||||||
|
req.setOperater(identifier);
|
||||||
|
return groupService.createGroup(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/getGroupInfo")
|
||||||
|
public ResponseVO getGroupInfo(@RequestBody @Validated GetGroupReq req, Integer appId) {
|
||||||
|
req.setAppId(appId);
|
||||||
|
return groupService.getGroup(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/update")
|
||||||
|
public ResponseVO update(@RequestBody @Validated UpdateGroupReq req, Integer appId, String identifier) {
|
||||||
|
req.setAppId(appId);
|
||||||
|
req.setOperater(identifier);
|
||||||
|
return groupService.updateBaseGroupInfo(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/getJoinedGroup")
|
||||||
|
public ResponseVO getJoinedGroup(@RequestBody @Validated GetJoinedGroupReq req, Integer appId, String identifier) {
|
||||||
|
req.setAppId(appId);
|
||||||
|
req.setOperater(identifier);
|
||||||
|
return groupService.getJoinedGroup(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping("/destroyGroup")
|
||||||
|
public ResponseVO destroyGroup(@RequestBody @Validated DestroyGroupReq req, Integer appId, String identifier) {
|
||||||
|
req.setAppId(appId);
|
||||||
|
req.setOperater(identifier);
|
||||||
|
return groupService.destroyGroup(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/transferGroup")
|
||||||
|
public ResponseVO transferGroup(@RequestBody @Validated TransferGroupReq req, Integer appId, String identifier) {
|
||||||
|
req.setAppId(appId);
|
||||||
|
req.setOperater(identifier);
|
||||||
|
return groupService.transferGroup(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/forbidSendMessage")
|
||||||
|
public ResponseVO forbidSendMessage(@RequestBody @Validated MuteGroupReq req, Integer appId, String identifier) {
|
||||||
|
req.setAppId(appId);
|
||||||
|
req.setOperater(identifier);
|
||||||
|
return groupService.muteGroup(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
package com.lld.im.service.group.controller;
|
||||||
|
|
||||||
|
import com.lld.im.common.ResponseVO;
|
||||||
|
import com.lld.im.service.group.model.req.*;
|
||||||
|
import com.lld.im.service.group.service.ImGroupMemberService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description:
|
||||||
|
* @author: lld
|
||||||
|
* @version: 1.0
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("v1/group/member")
|
||||||
|
public class ImGroupMemberController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
ImGroupMemberService groupMemberService;
|
||||||
|
|
||||||
|
@RequestMapping("/importGroupMember")
|
||||||
|
public ResponseVO importGroupMember(@RequestBody @Validated ImportGroupMemberReq req, Integer appId, String identifier) {
|
||||||
|
req.setAppId(appId);
|
||||||
|
req.setOperater(identifier);
|
||||||
|
return groupMemberService.importGroupMember(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/add")
|
||||||
|
public ResponseVO addMember(@RequestBody @Validated AddGroupMemberReq req, Integer appId, String identifier) {
|
||||||
|
req.setAppId(appId);
|
||||||
|
req.setOperater(identifier);
|
||||||
|
return groupMemberService.addMember(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/remove")
|
||||||
|
public ResponseVO removeMember(@RequestBody @Validated RemoveGroupMemberReq req, Integer appId, String identifier) {
|
||||||
|
req.setAppId(appId);
|
||||||
|
req.setOperater(identifier);
|
||||||
|
return groupMemberService.removeMember(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/update")
|
||||||
|
public ResponseVO updateGroupMember(@RequestBody @Validated UpdateGroupMemberReq req, Integer appId, String identifier) {
|
||||||
|
req.setAppId(appId);
|
||||||
|
req.setOperater(identifier);
|
||||||
|
return groupMemberService.updateGroupMember(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/speak")
|
||||||
|
public ResponseVO speak(@RequestBody @Validated SpeaMemberReq req, Integer appId, String identifier) {
|
||||||
|
req.setAppId(appId);
|
||||||
|
req.setOperater(identifier);
|
||||||
|
return groupMemberService.speak(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
package com.lld.im.service.group.dao;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description:
|
||||||
|
* @author: lld
|
||||||
|
* @version: 1.0
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@TableName("im_group")
|
||||||
|
public class ImGroupEntity {
|
||||||
|
|
||||||
|
@TableId(value = "group_id")
|
||||||
|
private String groupId;
|
||||||
|
|
||||||
|
private Integer appId;
|
||||||
|
|
||||||
|
//群主id
|
||||||
|
private String ownerId;
|
||||||
|
|
||||||
|
//群类型 1私有群(类似微信) 2公开群(类似qq)
|
||||||
|
private Integer groupType;
|
||||||
|
|
||||||
|
private String groupName;
|
||||||
|
|
||||||
|
private Integer mute;// 是否全员禁言,0 不禁言;1 全员禁言。
|
||||||
|
|
||||||
|
// 申请加群选项包括如下几种:
|
||||||
|
// 0 表示禁止任何人申请加入
|
||||||
|
// 1 表示需要群主或管理员审批
|
||||||
|
// 2 表示允许无需审批自由加入群组
|
||||||
|
private Integer applyJoinType;
|
||||||
|
|
||||||
|
private String introduction;//群简介
|
||||||
|
|
||||||
|
private String notification;//群公告
|
||||||
|
|
||||||
|
private String photo;//群头像
|
||||||
|
|
||||||
|
private Integer maxMemberCount;//群成员上限
|
||||||
|
|
||||||
|
private Integer status;//群状态 0正常 1解散
|
||||||
|
|
||||||
|
private Long sequence;
|
||||||
|
|
||||||
|
private Long createTime;
|
||||||
|
|
||||||
|
private Long updateTime;
|
||||||
|
|
||||||
|
private String extra;
|
||||||
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
package com.lld.im.service.group.dao;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description:
|
||||||
|
* @author: lld
|
||||||
|
* @version: 1.0
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@TableName("im_group_member")
|
||||||
|
public class ImGroupMemberEntity {
|
||||||
|
|
||||||
|
@TableId(type = IdType.AUTO)
|
||||||
|
private Long groupMemberId;
|
||||||
|
|
||||||
|
private Integer appId;
|
||||||
|
|
||||||
|
private String groupId;
|
||||||
|
|
||||||
|
//成员id
|
||||||
|
private String memberId;
|
||||||
|
|
||||||
|
//群成员类型,0 普通成员, 1 管理员, 2 群主, 3 禁言,4 已经移除的成员
|
||||||
|
private Integer role;
|
||||||
|
|
||||||
|
private Long speakDate;
|
||||||
|
|
||||||
|
//群昵称
|
||||||
|
private String alias;
|
||||||
|
|
||||||
|
//加入时间
|
||||||
|
private Long joinTime;
|
||||||
|
|
||||||
|
//离开时间
|
||||||
|
private Long leaveTime;
|
||||||
|
|
||||||
|
private String joinType;
|
||||||
|
|
||||||
|
private String extra;
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package com.lld.im.service.group.dao;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author: Chackylee
|
||||||
|
* @description:
|
||||||
|
**/
|
||||||
|
@Data
|
||||||
|
@TableName("im_group_message_history")
|
||||||
|
public class ImGroupMessageHistoryEntity {
|
||||||
|
|
||||||
|
private Integer appId;
|
||||||
|
|
||||||
|
private String fromId;
|
||||||
|
|
||||||
|
private String groupId;
|
||||||
|
|
||||||
|
/** messageBodyId*/
|
||||||
|
private Long messageKey;
|
||||||
|
/** 序列号*/
|
||||||
|
private Long sequence;
|
||||||
|
|
||||||
|
private String messageRandom;
|
||||||
|
|
||||||
|
private Long messageTime;
|
||||||
|
|
||||||
|
private Long createTime;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package com.lld.im.service.group.dao.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.lld.im.service.group.dao.ImGroupEntity;
|
||||||
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface ImGroupMapper extends BaseMapper<ImGroupEntity> {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
package com.lld.im.service.group.dao.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.lld.im.service.group.dao.ImGroupMemberEntity;
|
||||||
|
import com.lld.im.service.group.model.req.GroupMemberDto;
|
||||||
|
import org.apache.ibatis.annotations.Result;
|
||||||
|
import org.apache.ibatis.annotations.Results;
|
||||||
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface ImGroupMemberMapper extends BaseMapper<ImGroupMemberEntity> {
|
||||||
|
|
||||||
|
@Select("select group_id from im_group_member where app_id = #{appId} AND member_id = #{memberId} ")
|
||||||
|
public List<String> getJoinedGroupId(Integer appId, String memberId);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Results({
|
||||||
|
@Result(column = "member_id", property = "memberId"),
|
||||||
|
// @Result(column = "speak_flag", property = "speakFlag"),
|
||||||
|
@Result(column = "speak_date", property = "speakDate"),
|
||||||
|
@Result(column = "role", property = "role"),
|
||||||
|
@Result(column = "alias", property = "alias"),
|
||||||
|
@Result(column = "join_time", property = "joinTime"),
|
||||||
|
@Result(column = "join_type", property = "joinType")
|
||||||
|
})
|
||||||
|
@Select("select " +
|
||||||
|
" member_id, " +
|
||||||
|
// " speak_flag, " +
|
||||||
|
" speak_date, " +
|
||||||
|
" role, " +
|
||||||
|
" alias, " +
|
||||||
|
" join_time ," +
|
||||||
|
" join_type " +
|
||||||
|
" from im_group_member where app_id = #{appId} AND group_id = #{groupId} ")
|
||||||
|
public List<GroupMemberDto> getGroupMember(Integer appId, String groupId);
|
||||||
|
|
||||||
|
@Select("select " +
|
||||||
|
" member_id " +
|
||||||
|
" from im_group_member where app_id = #{appId} AND group_id = #{groupId} and role != 3")
|
||||||
|
public List<String> getGroupMemberId(Integer appId, String groupId);
|
||||||
|
|
||||||
|
|
||||||
|
@Results({
|
||||||
|
@Result(column = "member_id", property = "memberId"),
|
||||||
|
// @Result(column = "speak_flag", property = "speakFlag"),
|
||||||
|
@Result(column = "role", property = "role")
|
||||||
|
// @Result(column = "alias", property = "alias"),
|
||||||
|
// @Result(column = "join_time", property = "joinTime"),
|
||||||
|
// @Result(column = "join_type", property = "joinType")
|
||||||
|
})
|
||||||
|
@Select("select " +
|
||||||
|
" member_id, " +
|
||||||
|
// " speak_flag, " +
|
||||||
|
" role " +
|
||||||
|
// " alias, " +
|
||||||
|
// " join_time ," +
|
||||||
|
// " join_type " +
|
||||||
|
" from im_group_member where app_id = #{appId} AND group_id = #{groupId} and role in (1,2) ")
|
||||||
|
public List<GroupMemberDto> getGroupManager(String groupId, Integer appId);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package com.lld.im.service.group.dao.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.lld.im.service.group.dao.ImGroupMessageHistoryEntity;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface ImGroupMessageHistoryMapper extends BaseMapper<ImGroupMessageHistoryEntity> {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package com.lld.im.service.group.model.req;
|
||||||
|
|
||||||
|
import com.lld.im.common.model.RequestBase;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import javax.validation.constraints.NotEmpty;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description:
|
||||||
|
* @author: lld
|
||||||
|
* @version: 1.0
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class AddGroupMemberReq extends RequestBase {
|
||||||
|
|
||||||
|
@NotBlank(message = "群id不能为空")
|
||||||
|
private String groupId;
|
||||||
|
|
||||||
|
@NotEmpty(message = "群成员不能为空")
|
||||||
|
private List<GroupMemberDto> members;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
package com.lld.im.service.group.model.req;
|
||||||
|
|
||||||
|
import com.lld.im.common.model.RequestBase;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description:
|
||||||
|
* @author: lld
|
||||||
|
* @version: 1.0
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class CreateGroupReq extends RequestBase {
|
||||||
|
|
||||||
|
private String groupId;
|
||||||
|
//群主id
|
||||||
|
private String ownerId;
|
||||||
|
|
||||||
|
//群类型 1私有群(类似微信) 2公开群(类似qq)
|
||||||
|
private Integer groupType;
|
||||||
|
|
||||||
|
private String groupName;
|
||||||
|
|
||||||
|
private Integer mute;// 是否全员禁言,0 不禁言;1 全员禁言。
|
||||||
|
|
||||||
|
private Integer applyJoinType;//加入群权限,0 所有人可以加入;1 群成员可以拉人;2 群管理员或群组可以拉人。
|
||||||
|
|
||||||
|
private String introduction;//群简介
|
||||||
|
|
||||||
|
private String notification;//群公告
|
||||||
|
|
||||||
|
private String photo;//群头像
|
||||||
|
|
||||||
|
private Integer MaxMemberCount;
|
||||||
|
|
||||||
|
private List<GroupMemberDto> member;
|
||||||
|
|
||||||
|
private String extra;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package com.lld.im.service.group.model.req;
|
||||||
|
|
||||||
|
import com.lld.im.common.model.RequestBase;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author: Chackylee
|
||||||
|
* @description:
|
||||||
|
**/
|
||||||
|
@Data
|
||||||
|
public class DestroyGroupReq extends RequestBase {
|
||||||
|
|
||||||
|
@NotNull(message = "群id不能为空")
|
||||||
|
private String groupId;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package com.lld.im.service.group.model.req;
|
||||||
|
|
||||||
|
import com.lld.im.common.model.RequestBase;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author: Chackylee
|
||||||
|
* @description:
|
||||||
|
**/
|
||||||
|
@Data
|
||||||
|
public class GetGroupReq extends RequestBase {
|
||||||
|
|
||||||
|
private String groupId;
|
||||||
|
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user