Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
WeiPanAPI
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Discuz
WeiPanAPI
Commits
43a57c84
Commit
43a57c84
authored
Mar 02, 2021
by
xiongyuwen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
no message
parent
616f8d1f
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
391 additions
and
0 deletions
+391
-0
GetNotificationsRequest.cs
...lication/WeiPan/Dto/RequestDto/GetNotificationsRequest.cs
+15
-0
GetNoticeListResponse.cs
...plication/WeiPan/Dto/ResponseDto/GetNoticeListResponse.cs
+34
-0
GetNotificationsResponse.cs
...cation/WeiPan/Dto/ResponseDto/GetNotificationsResponse.cs
+146
-0
GetUserByMobileResponse.cs
...ication/WeiPan/Dto/ResponseDto/GetUserByMobileResponse.cs
+40
-0
IWeiPanService.cs
src/Bailun.Discuz.Application/WeiPan/IWeiPanService.cs
+2
-0
WeiPanService.cs
src/Bailun.Discuz.Application/WeiPan/WeiPanService.cs
+147
-0
WeiPanController.cs
src/Bailun.Discuz.Service/Controllers/WeiPanController.cs
+7
-0
No files found.
src/Bailun.Discuz.Application/WeiPan/Dto/RequestDto/GetNotificationsRequest.cs
0 → 100644
View file @
43a57c84
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
namespace
Bailun.Discuz.Application.WeiPan.Dto.RequestDto
{
public
class
GetNotificationsRequest
{
public
string
phone
{
get
;
set
;
}
public
int
pageIndex
{
get
;
set
;
}
public
int
pageSize
{
get
;
set
;
}
}
}
src/Bailun.Discuz.Application/WeiPan/Dto/ResponseDto/GetNoticeListResponse.cs
0 → 100644
View file @
43a57c84
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
namespace
Bailun.Discuz.Application.WeiPan.Dto.ResponseDto
{
public
class
NoticeListItem
{
/// <summary>
///
/// </summary>
public
string
id
{
get
;
set
;
}
/// <summary>
/// 私信
/// </summary>
public
string
noticeType
{
get
;
set
;
}
/// <summary>
///
/// </summary>
public
string
noticeUrl
{
get
;
set
;
}
}
public
class
GetNoticeListResponse
{
/// <summary>
///
/// </summary>
public
string
total
{
get
;
set
;
}
/// <summary>
///
/// </summary>
public
List
<
NoticeListItem
>
noticeList
{
get
;
set
;
}
}
}
src/Bailun.Discuz.Application/WeiPan/Dto/ResponseDto/GetNotificationsResponse.cs
0 → 100644
View file @
43a57c84
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
namespace
Bailun.Discuz.Application.WeiPan.Dto.ResponseDto
{
public
class
Links
{
/// <summary>
///
/// </summary>
public
string
first
{
get
;
set
;
}
/// <summary>
///
/// </summary>
public
string
last
{
get
;
set
;
}
}
public
class
NotificationsAttributes
{
public
string
noticetype
{
get
;
set
;
}
public
string
noticeurl
{
get
;
set
;
}
/// <summary>
///
/// </summary>
public
int
id
{
get
;
set
;
}
/// <summary>
///
/// </summary>
public
string
type
{
get
;
set
;
}
/// <summary>
///
/// </summary>
public
int
user_id
{
get
;
set
;
}
/// <summary>
///
/// </summary>
public
string
read_at
{
get
;
set
;
}
/// <summary>
///
/// </summary>
public
string
created_at
{
get
;
set
;
}
/// <summary>
///
/// </summary>
public
int
thread_id
{
get
;
set
;
}
/// <summary>
/// 冯晓茵
/// </summary>
public
string
thread_username
{
get
;
set
;
}
/// <summary>
/// 园区周边餐饮介绍
/// </summary>
public
string
thread_title
{
get
;
set
;
}
/// <summary>
///
/// </summary>
public
string
thread_created_at
{
get
;
set
;
}
/// <summary>
///
/// </summary>
public
int
post_id
{
get
;
set
;
}
/// <summary>
///
/// </summary>
public
string
post_content
{
get
;
set
;
}
/// <summary>
///
/// </summary>
public
int
reply_post_id
{
get
;
set
;
}
/// <summary>
///
/// </summary>
public
string
post_created_at
{
get
;
set
;
}
/// <summary>
///
/// </summary>
public
string
reply_post_user_name
{
get
;
set
;
}
/// <summary>
/// 冯晓茵
/// </summary>
public
string
user_name
{
get
;
set
;
}
/// <summary>
///
/// </summary>
public
string
user_avatar
{
get
;
set
;
}
/// <summary>
///
/// </summary>
public
string
isReal
{
get
;
set
;
}
/// <summary>
/// 普通会员
/// </summary>
public
string
thread_user_groups
{
get
;
set
;
}
/// <summary>
///
/// </summary>
public
int
thread_is_approved
{
get
;
set
;
}
}
public
class
DataItem
{
/// <summary>
///
/// </summary>
public
string
type
{
get
;
set
;
}
/// <summary>
///
/// </summary>
public
string
id
{
get
;
set
;
}
/// <summary>
///
/// </summary>
public
NotificationsAttributes
attributes
{
get
;
set
;
}
}
public
class
Meta
{
/// <summary>
///
/// </summary>
public
int
total
{
get
;
set
;
}
/// <summary>
///
/// </summary>
public
int
pageCount
{
get
;
set
;
}
}
public
class
GetNotificationsResponse
{
/// <summary>
///
/// </summary>
public
Links
links
{
get
;
set
;
}
/// <summary>
///
/// </summary>
public
List
<
DataItem
>
data
{
get
;
set
;
}
/// <summary>
///
/// </summary>
public
Meta
meta
{
get
;
set
;
}
}
}
src/Bailun.Discuz.Application/WeiPan/Dto/ResponseDto/GetUserByMobileResponse.cs
0 → 100644
View file @
43a57c84
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
namespace
Bailun.Discuz.Application.WeiPan.Dto.ResponseDto
{
//如果好用,请收藏地址,帮忙分享。
public
class
UserByMobileResult
{
/// <summary>
/// 熊裕文
/// </summary>
public
string
userName
{
get
;
set
;
}
/// <summary>
///
/// </summary>
public
int
userId
{
get
;
set
;
}
/// <summary>
///
/// </summary>
public
string
wxUserId
{
get
;
set
;
}
}
public
class
GetUserByMobileResponse
{
/// <summary>
///
/// </summary>
public
UserByMobileResult
result
{
get
;
set
;
}
/// <summary>
///
/// </summary>
public
int
statusCode
{
get
;
set
;
}
/// <summary>
///
/// </summary>
public
string
message
{
get
;
set
;
}
}
}
src/Bailun.Discuz.Application/WeiPan/IWeiPanService.cs
View file @
43a57c84
using
Abp.Application.Services
;
using
Abp.Application.Services
;
using
Abp.Domain.Services
;
using
Abp.Domain.Services
;
using
Bailun.Discuz.Application.Account.Dto
;
using
Bailun.Discuz.Application.Account.Dto
;
using
Bailun.Discuz.Application.WeiPan.Dto.RequestDto
;
using
Bailun.Discuz.Application.WeiPan.Dto.ResponseDto
;
using
Bailun.Discuz.Application.WeiPan.Dto.ResponseDto
;
using
Bailun.Discuz.Domain.WeiPan
;
using
Bailun.Discuz.Domain.WeiPan
;
using
System
;
using
System
;
...
@@ -55,5 +56,6 @@ namespace Bailun.Discuz.Application.WeiPan
...
@@ -55,5 +56,6 @@ namespace Bailun.Discuz.Application.WeiPan
Task
<
string
>
ProcessWeiPanWorker
(
string
userId
,
string
companyName
);
Task
<
string
>
ProcessWeiPanWorker
(
string
userId
,
string
companyName
);
Task
<
WeiPanFileList
>
GetWeiPanFileByThreadId
(
long
threadId
);
Task
<
WeiPanFileList
>
GetWeiPanFileByThreadId
(
long
threadId
);
Task
<
WeiPanFileList
>
GetFileInfo
(
string
fileId
);
Task
<
WeiPanFileList
>
GetFileInfo
(
string
fileId
);
Task
<
GetNotificationsResponse
>
GetNoticeList
(
GetNotificationsRequest
request
);
}
}
}
}
src/Bailun.Discuz.Application/WeiPan/WeiPanService.cs
View file @
43a57c84
...
@@ -1012,6 +1012,17 @@ namespace Bailun.Discuz.Application.WeiPan
...
@@ -1012,6 +1012,17 @@ namespace Bailun.Discuz.Application.WeiPan
HttpResponseMessage
response
=
client
.
PostAsync
(
requestUri
,
content
).
Result
;
HttpResponseMessage
response
=
client
.
PostAsync
(
requestUri
,
content
).
Result
;
return
response
.
Content
.
ReadAsStringAsync
().
Result
;
return
response
.
Content
.
ReadAsStringAsync
().
Result
;
}
}
public
string
Client_Get
(
string
requestUri
,
string
token
)
{
var
client
=
new
HttpClient
();
//添加请求头
if
(!
string
.
IsNullOrWhiteSpace
(
token
))
{
client
.
DefaultRequestHeaders
.
Add
(
"Authorization"
,
token
);
}
HttpResponseMessage
response
=
client
.
GetAsync
(
requestUri
).
Result
;
return
response
.
Content
.
ReadAsStringAsync
().
Result
;
}
List
<
ItemItem
>
fileItems
=
new
List
<
ItemItem
>();
List
<
ItemItem
>
fileItems
=
new
List
<
ItemItem
>();
//}
//}
...
@@ -1109,5 +1120,141 @@ namespace Bailun.Discuz.Application.WeiPan
...
@@ -1109,5 +1120,141 @@ namespace Bailun.Discuz.Application.WeiPan
});
});
return
weiPanFileLists
;
return
weiPanFileLists
;
}
}
public
async
Task
<
GetNotificationsResponse
>
GetNoticeList
(
GetNotificationsRequest
request
)
{
var
noticeList
=
new
List
<
NoticeListItem
>();
if
(
request
.
phone
.
IsNullOrEmpty
())
throw
new
Exception
(
"请输入手机号码"
);
//根据手机号码获取用户id
var
url
=
$"https://sso.bailuntec.com/GetUserByMobile?mobile=
{
request
.
phone
}
"
;
var
response
=
HttpHelper
.
HttpGet
(
url
);
var
result
=
JsonHelper
.
FromJson
<
GetUserByMobileResponse
>(
response
);
if
(
result
.
statusCode
!=
200
)
{
throw
new
Exception
(
"查无此人"
);
}
var
wxUserId
=
result
.
result
.
wxUserId
;
//通过用户id获取对应得token
response
=
HttpHelper
.
HttpGet
(
$"http://discuz.bailuntec.com/api/login?useid=
{
wxUserId
}
"
);
var
resultToken
=
JsonHelper
.
FromJson
<
GetDiscuzTokenRespnse
>(
response
);
var
token
=
resultToken
.
data
.
attributes
.
access_token
;
//根据token获取对应未读的消息
response
=
Client_Get
(
$"http://discuz.bailuntec.com/api/notification?page[number]=
{
request
.
pageIndex
}
&page[limit]=
{
request
.
pageSize
}
&filter[isNotRead]=1"
,
token
);
response
=
Regex
.
Unescape
(
response
);
response
=
HttpUtility
.
UrlDecode
(
response
);
var
resultNotifications
=
JsonHelper
.
FromJson
<
GetNotificationsResponse
>(
response
);
if
(
resultNotifications
.
data
!=
null
&&
resultNotifications
.
data
.
Count
>
0
)
{
foreach
(
var
item
in
resultNotifications
.
data
)
{
item
.
attributes
.
noticetype
=
GetNoticeType
(
item
.
attributes
.
type
);
item
.
attributes
.
noticeurl
=
await
GetNoticeUrlByThreadId
(
item
.
attributes
.
thread_id
,
wxUserId
);
}
}
return
resultNotifications
;
}
/// <summary>
/// 字符串转Unicode
/// </summary>
/// <param name="source">源字符串</param>
/// <returns>Unicode编码后的字符串</returns>
public
static
string
String2Unicode
(
string
source
)
{
var
bytes
=
Encoding
.
Unicode
.
GetBytes
(
source
);
var
stringBuilder
=
new
StringBuilder
();
for
(
var
i
=
0
;
i
<
bytes
.
Length
;
i
+=
2
)
{
stringBuilder
.
AppendFormat
(
"\\u{0:x2}{1:x2}"
,
bytes
[
i
+
1
],
bytes
[
i
]);
}
return
stringBuilder
.
ToString
();
}
/// <summary>
/// 字符串转为UniCode码字符串
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
public
static
string
StringToUnicode
(
string
s
)
{
char
[]
charbuffers
=
s
.
ToCharArray
();
byte
[]
buffer
;
StringBuilder
sb
=
new
StringBuilder
();
for
(
int
i
=
0
;
i
<
charbuffers
.
Length
;
i
++)
{
buffer
=
System
.
Text
.
Encoding
.
Unicode
.
GetBytes
(
charbuffers
[
i
].
ToString
());
sb
.
Append
(
String
.
Format
(
"\\u{0:X2}{1:X2}"
,
buffer
[
1
],
buffer
[
0
]));
}
return
sb
.
ToString
();
}
/// <summary>
/// Unicode字符串转为正常字符串
/// </summary>
/// <param name="srcText"></param>
/// <returns></returns>
public
static
string
UnicodeToString
(
string
srcText
)
{
string
dst
=
""
;
string
src
=
srcText
;
int
len
=
srcText
.
Length
/
6
;
for
(
int
i
=
0
;
i
<=
len
-
1
;
i
++)
{
string
str
=
""
;
str
=
src
.
Substring
(
0
,
6
).
Substring
(
2
);
src
=
src
.
Substring
(
6
);
byte
[]
bytes
=
new
byte
[
2
];
bytes
[
1
]
=
byte
.
Parse
(
int
.
Parse
(
str
.
Substring
(
0
,
2
),
System
.
Globalization
.
NumberStyles
.
HexNumber
).
ToString
());
bytes
[
0
]
=
byte
.
Parse
(
int
.
Parse
(
str
.
Substring
(
2
,
2
),
System
.
Globalization
.
NumberStyles
.
HexNumber
).
ToString
());
dst
+=
Encoding
.
Unicode
.
GetString
(
bytes
);
}
return
dst
;
}
/// <summary>
/// 根据帖子id返回对应得帖子地址
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public
async
Task
<
string
>
GetNoticeUrlByThreadId
(
int
id
,
string
userId
)
{
var
weiPanFile
=
await
GetWeiPanFileByThreadId
(
id
);
string
resUrl
=
""
;
if
(
weiPanFile
!=
null
)
{
resUrl
=
$"https://discuz.bailuntec.com/pages/knowledge/details?firstFileId=
{
weiPanFile
.
FirstFileId
}
&fatherId=
{
weiPanFile
.
FileId
}
&userId=
{
userId
}
"
;
}
else
{
resUrl
=
$"https://discuz.bailuntec.com/topic/index?id=
{
id
}
"
;
}
return
resUrl
;
}
public
string
GetNoticeType
(
string
type
)
{
string
res
=
""
;
switch
(
type
)
{
case
"liked"
:
res
=
"点赞我的"
;
break
;
case
"questioned"
:
res
=
"问答通知"
;
break
;
case
"related"
:
res
=
"@我的"
;
break
;
case
"replied"
:
res
=
"回复我的"
;
break
;
case
"system"
:
res
=
"系统通知"
;
break
;
case
"chat"
:
res
=
"私信"
;
break
;
default
:
break
;
}
return
res
;
}
}
}
}
}
src/Bailun.Discuz.Service/Controllers/WeiPanController.cs
View file @
43a57c84
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
using
Bailun.Discuz.Application.Account.Dto
;
using
Bailun.Discuz.Application.Account.Dto
;
using
Bailun.Discuz.Application.Util
;
using
Bailun.Discuz.Application.Util
;
using
Bailun.Discuz.Application.WeiPan
;
using
Bailun.Discuz.Application.WeiPan
;
using
Bailun.Discuz.Application.WeiPan.Dto.RequestDto
;
using
Bailun.Discuz.Application.WeiPan.Dto.ResponseDto
;
using
Bailun.Discuz.Application.WeiPan.Dto.ResponseDto
;
using
Bailun.Discuz.Domain.WeiPan
;
using
Bailun.Discuz.Domain.WeiPan
;
using
Microsoft.AspNetCore.Mvc
;
using
Microsoft.AspNetCore.Mvc
;
...
@@ -101,5 +102,11 @@ namespace Bailun.Discuz.Service.Controllers
...
@@ -101,5 +102,11 @@ namespace Bailun.Discuz.Service.Controllers
{
{
return
await
_iweiPanService
.
GetAttchmattachmentByFileId
(
fileId
);
return
await
_iweiPanService
.
GetAttchmattachmentByFileId
(
fileId
);
}
}
[
HttpPost
(
"GetNoticeList"
)]
public
async
Task
<
GetNotificationsResponse
>
GetNoticeList
(
GetNotificationsRequest
request
)
{
return
await
_iweiPanService
.
GetNoticeList
(
request
);
}
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment