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
c057398b
Commit
c057398b
authored
May 13, 2021
by
xiongyuwen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
no message
parent
4b5cd287
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
21 deletions
+41
-21
IWeiPanService.cs
src/Bailun.Discuz.Application/WeiPan/IWeiPanService.cs
+1
-1
WeiPanService.cs
src/Bailun.Discuz.Application/WeiPan/WeiPanService.cs
+37
-17
WeiPanController.cs
src/Bailun.Discuz.Service/Controllers/WeiPanController.cs
+3
-3
No files found.
src/Bailun.Discuz.Application/WeiPan/IWeiPanService.cs
View file @
c057398b
...
@@ -57,6 +57,6 @@ namespace Bailun.Discuz.Application.WeiPan
...
@@ -57,6 +57,6 @@ namespace Bailun.Discuz.Application.WeiPan
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
);
Task
<
GetNotificationsResponse
>
GetNoticeList
(
GetNotificationsRequest
request
);
Task
<
bool
>
IsVisitFourkByUserId
(
string
userI
d
);
Task
<
bool
>
IsVisitFourkByUserId
(
int
?
i
d
);
}
}
}
}
src/Bailun.Discuz.Application/WeiPan/WeiPanService.cs
View file @
c057398b
...
@@ -467,9 +467,7 @@ namespace Bailun.Discuz.Application.WeiPan
...
@@ -467,9 +467,7 @@ namespace Bailun.Discuz.Application.WeiPan
string
fileUrl
=
""
;
string
fileUrl
=
""
;
try
try
{
{
// string fileUrl =(await GetFileUrl(md5))?.QiniuUrl;
Console
.
WriteLine
(
$"开始上传七牛云,当前文件名称为:
{
fileName
}
"
);
//if (fileUrl == null)
// {
GetViewFileReuqest
getViewFileRequest
=
new
GetViewFileReuqest
();
GetViewFileReuqest
getViewFileRequest
=
new
GetViewFileReuqest
();
getViewFileRequest
.
userid
=
userId
;
getViewFileRequest
.
userid
=
userId
;
getViewFileRequest
.
fileid
=
fileId
;
getViewFileRequest
.
fileid
=
fileId
;
...
@@ -533,7 +531,7 @@ namespace Bailun.Discuz.Application.WeiPan
...
@@ -533,7 +531,7 @@ namespace Bailun.Discuz.Application.WeiPan
{
{
throw
new
Exception
(
apiOutput
.
errmsg
);
throw
new
Exception
(
apiOutput
.
errmsg
);
}
}
// }
Console
.
WriteLine
(
$"上传七牛云成功,当前文件名称为:
{
fileName
}
"
);
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
{
{
...
@@ -745,7 +743,8 @@ namespace Bailun.Discuz.Application.WeiPan
...
@@ -745,7 +743,8 @@ namespace Bailun.Discuz.Application.WeiPan
//string value = "测试数据";
//string value = "测试数据";
//RedisHelper.Set("key", filList);
//RedisHelper.Set("key", filList);
//List<WeiPanFileList> filList = RedisHelper.Get<List<WeiPanFileList>>("key");
// List<WeiPanFileList> filList = RedisHelper.Get<List<WeiPanFileList>>("key");
//filList.RemoveAt(1);
//filList.RemoveAt(1);
//2:判断当前fileid是否存在于数据库中, 如果不存在则添加
//2:判断当前fileid是否存在于数据库中, 如果不存在则添加
foreach
(
var
file
in
filList
)
foreach
(
var
file
in
filList
)
...
@@ -756,6 +755,7 @@ namespace Bailun.Discuz.Application.WeiPan
...
@@ -756,6 +755,7 @@ namespace Bailun.Discuz.Application.WeiPan
//将文档上传至七牛云
//将文档上传至七牛云
string
fileUrl
=
await
GetViewFile
(
userId
,
file
.
FileId
,
file
.
FileMd5
,
file
.
FileName
);
string
fileUrl
=
await
GetViewFile
(
userId
,
file
.
FileId
,
file
.
FileMd5
,
file
.
FileName
);
file
.
QiniuUrl
=
fileUrl
;
file
.
QiniuUrl
=
fileUrl
;
_weiPanFileListRepository
.
InsertAndGetId
(
file
);
inserWeiPanFileList
.
Add
(
file
);
inserWeiPanFileList
.
Add
(
file
);
}
else
}
else
{
{
...
@@ -807,22 +807,32 @@ namespace Bailun.Discuz.Application.WeiPan
...
@@ -807,22 +807,32 @@ namespace Bailun.Discuz.Application.WeiPan
if
(
inserWeiPanFileList
.
Count
>
0
||
delFiles
.
Any
())
//有新增则清除缓存
if
(
inserWeiPanFileList
.
Count
>
0
||
delFiles
.
Any
())
//有新增则清除缓存
{
{
messageSb
.
Append
(
$"新增帖子数量为:
{
inserWeiPanFileList
.
Count
}
,分别为:
{
string
.
Join
(
","
,
inserWeiPanFileList
.
Select
(
u
=>
u
.
FileName
).
ToArray
())
}
;"
);
messageSb
.
Append
(
$"新增帖子数量为:
{
inserWeiPanFileList
.
Count
}
,分别为:
{
string
.
Join
(
","
,
inserWeiPanFileList
.
Select
(
u
=>
u
.
FileName
).
ToArray
())
}
;"
);
_weiPanFileListRepository
.
BulkInsert
(
inserWeiPanFileList
.
ToArray
());
//
_weiPanFileListRepository.BulkInsert(inserWeiPanFileList.ToArray());
RedisHelper
.
Del
(
Constants
.
File_List_Tree
+
companyName
);
//清除缓存
RedisHelper
.
Del
(
Constants
.
File_List_Tree
+
$"_
{
companyName
}
"
);
//清除缓存
RedisHelper
.
Del
(
Constants
.
First_File_List
+
companyName
);
//清除缓存
RedisHelper
.
Del
(
Constants
.
First_File_List
+
$"_
{
companyName
}
"
);
//清除缓存
await
CreateUserFilesTreeRedis
(
companyName
);
await
CreateUserFilesTreeRedis
(
companyName
);
}
}
var
noTieZilist
=
await
_weiPanFileListRepository
.
Query
().
AsNoTracking
().
Where
(
u
=>
u
.
ThreadId
==
0
&&
u
.
CompanyName
==
companyName
).
ToListAsync
();
var
noTieZilist
=
await
_weiPanFileListRepository
.
Query
().
AsNoTracking
().
Where
(
u
=>
u
.
ThreadId
==
0
&&
u
.
CompanyName
==
companyName
&&!
u
.
QiniuUrl
.
IsNullOrEmpty
()
).
ToListAsync
();
foreach
(
var
item
in
noTieZilist
)
foreach
(
var
item
in
noTieZilist
)
{
{
try
{
//对新增的文档进行创建帖子
//对新增的文档进行创建帖子
var
threadId
=
await
PublishTieZi
(
item
);
var
threadId
=
await
PublishTieZi
(
item
);
if
(!
string
.
IsNullOrEmpty
(
threadId
))
if
(!
string
.
IsNullOrEmpty
(
threadId
))
{
{
item
.
ThreadId
=
Convert
.
ToInt64
(
threadId
);
item
.
ThreadId
=
Convert
.
ToInt64
(
threadId
);
await
_weiPanFileListRepository
.
UpdateAsync
(
item
);
_weiPanFileListRepository
.
UpdateCommit
(
item
);
Console
.
WriteLine
(
$"生成帖子文件名称为:
{
item
.
FileName
}
成功,帖子ID为
{
threadId
}
"
);
}
}
catch
(
Exception
ex
)
{
Console
.
WriteLine
(
$"生成帖子文件名称为:
{
item
.
FileName
}
异常,异常结果
{
ex
.
Message
}
"
);
}
}
}
}
filList
=
null
;
filList
=
null
;
return
messageSb
.
Length
==
0
?
"无新增帖子"
:
messageSb
.
ToString
();
return
messageSb
.
Length
==
0
?
"无新增帖子"
:
messageSb
.
ToString
();
...
@@ -1049,9 +1059,16 @@ namespace Bailun.Discuz.Application.WeiPan
...
@@ -1049,9 +1059,16 @@ namespace Bailun.Discuz.Application.WeiPan
}
}
public
async
Task
<
string
>
PublishTieZi
(
WeiPanFileList
weiPanFile
)
public
async
Task
<
string
>
PublishTieZi
(
WeiPanFileList
weiPanFile
)
{
{
string
userId
=
weiPanFile
.
FileCreateUseid
;
string
resultId
=
""
;
string
resultId
=
""
;
userId
=
weiPanFile
.
CompanyName
==
"四千里数据科技有限公司"
?
"gaodesheng"
:
userId
;
//获取token
//获取token
var
response
=
HttpHelper
.
HttpGet
(
$"http://discuz.bailuntec.com/api/login?useid=
{
weiPanFile
.
FileCreateUseid
}
"
);
var
response
=
HttpHelper
.
HttpGet
(
$"http://discuz.bailuntec.com/api/login?useid=
{
userId
}
"
);
if
(
response
.
IsNullOrEmpty
())
{
userId
=
weiPanFile
.
CompanyName
==
"四千里数据科技有限公司"
?
"gaodesheng"
:
"fengxiaoyin"
;
response
=
HttpHelper
.
HttpGet
(
$"http://discuz.bailuntec.com/api/login?useid=
{
userId
}
"
);
}
var
result
=
JsonHelper
.
FromJson
<
GetDiscuzTokenRespnse
>(
response
);
var
result
=
JsonHelper
.
FromJson
<
GetDiscuzTokenRespnse
>(
response
);
var
token
=
result
.
data
.
attributes
.
access_token
;
var
token
=
result
.
data
.
attributes
.
access_token
;
//生成附件
//生成附件
...
@@ -1084,7 +1101,7 @@ namespace Bailun.Discuz.Application.WeiPan
...
@@ -1084,7 +1101,7 @@ namespace Bailun.Discuz.Application.WeiPan
var
apiUrl
=
$"http://discuz.bailuntec.com/api/threads"
;
var
apiUrl
=
$"http://discuz.bailuntec.com/api/threads"
;
var
res
=
JsonHelper
.
ToObject
<
PublishTieZiResponse
>(
Client_Post
(
publishTieZiRequest
.
ToJson
(),
apiUrl
,
"Bearer "
+
token
));
var
res
=
JsonHelper
.
ToObject
<
PublishTieZiResponse
>(
Client_Post
(
publishTieZiRequest
.
ToJson
(),
apiUrl
,
"Bearer "
+
token
));
//通知对应的用户
//通知对应的用户
var
users
=
await
GetNoticeUserNames
(
weiPanFile
.
FileId
,
weiPanFile
.
FileCreateUsei
d
);
var
users
=
await
GetNoticeUserNames
(
weiPanFile
.
FileId
,
userI
d
);
resultId
=
res
.
data
.
id
;
resultId
=
res
.
data
.
id
;
PostNoticeByNewTieZi
(
users
,
resultId
,
token
);
PostNoticeByNewTieZi
(
users
,
resultId
,
token
);
}
}
...
@@ -1216,7 +1233,7 @@ namespace Bailun.Discuz.Application.WeiPan
...
@@ -1216,7 +1233,7 @@ namespace Bailun.Discuz.Application.WeiPan
weiPanFile
.
CompanyName
=
companyName
;
weiPanFile
.
CompanyName
=
companyName
;
weiPanFile
.
FirstFileId
=
u
.
firstfileid
;
weiPanFile
.
FirstFileId
=
u
.
firstfileid
;
weiPanFile
.
QiniuUrl
=
""
;
weiPanFile
.
QiniuUrl
=
""
;
weiPanFile
.
FileCreateUseid
=
u
.
create_userid
;
weiPanFile
.
FileCreateUseid
=
u
.
create_userid
.
ToLower
()
;
weiPanFile
.
FirstFileName
=
u
.
firstFileName
;
weiPanFile
.
FirstFileName
=
u
.
firstFileName
;
weiPanFileLists
.
Add
(
weiPanFile
);
weiPanFileLists
.
Add
(
weiPanFile
);
});
});
...
@@ -1227,13 +1244,16 @@ namespace Bailun.Discuz.Application.WeiPan
...
@@ -1227,13 +1244,16 @@ namespace Bailun.Discuz.Application.WeiPan
/// </summary>
/// </summary>
/// <param name="userId"></param>
/// <param name="userId"></param>
/// <returns></returns>
/// <returns></returns>
public
async
Task
<
bool
>
IsVisitFourkByUserId
(
string
userI
d
)
public
async
Task
<
bool
>
IsVisitFourkByUserId
(
int
?
i
d
)
{
{
var
user
=
_usersRepository
.
Query
().
AsNoTracking
().
Where
(
u
=>
u
.
UserId
==
userId
).
FirstOrDefault
();
if
(
id
.
HasValue
)
{
var
user
=
_usersRepository
.
Query
().
AsNoTracking
().
Where
(
u
=>
u
.
Id
==
id
.
Value
).
FirstOrDefault
();
if
(
user
!=
null
)
if
(
user
!=
null
)
{
{
return
user
.
VisitFourK
;
return
user
.
VisitFourK
;
}
}
}
return
false
;
return
false
;
}
}
public
async
Task
<
GetNotificationsResponse
>
GetNoticeList
(
GetNotificationsRequest
request
)
public
async
Task
<
GetNotificationsResponse
>
GetNoticeList
(
GetNotificationsRequest
request
)
...
...
src/Bailun.Discuz.Service/Controllers/WeiPanController.cs
View file @
c057398b
...
@@ -109,10 +109,10 @@ namespace Bailun.Discuz.Service.Controllers
...
@@ -109,10 +109,10 @@ namespace Bailun.Discuz.Service.Controllers
return
await
_iweiPanService
.
GetNoticeList
(
request
);
return
await
_iweiPanService
.
GetNoticeList
(
request
);
}
}
[
HttpGet
(
"
i
sVisitFourkByUserId"
)]
[
HttpGet
(
"
I
sVisitFourkByUserId"
)]
public
async
Task
<
bool
>
IsVisitFourkByUserId
(
string
userI
d
)
public
async
Task
<
bool
>
IsVisitFourkByUserId
(
int
?
i
d
)
{
{
return
await
_iweiPanService
.
IsVisitFourkByUserId
(
userI
d
);
return
await
_iweiPanService
.
IsVisitFourkByUserId
(
i
d
);
}
}
}
}
}
}
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