Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
Education
Project
Project
Details
Activity
Releases
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
黄奎
Education
Commits
9a419340
Commit
9a419340
authored
Jan 18, 2022
by
黄奎
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
页面修改
parent
d106e9d3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
116 additions
and
43 deletions
+116
-43
LearningGardenModule.cs
Edu.Module.Course/LearningGardenModule.cs
+24
-24
RB_LearningGardenRepository.cs
Edu.Repository/LearningGarden/RB_LearningGardenRepository.cs
+36
-0
SchoolGardenController.cs
...bApi/Controllers/LearningGarden/SchoolGardenController.cs
+56
-19
No files found.
Edu.Module.Course/LearningGardenModule.cs
View file @
9a419340
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
using
System.Threading.Tasks
;
using
Edu.Model.ViewModel.LearningGarden
;
using
Edu.Repository.LearningGarden
;
using
VT.FW.DB
;
...
...
@@ -68,10 +69,6 @@ namespace Edu.Module.Course
return
flag
;
}
/// <summary>
/// 批量新增修改学习园地
/// </summary>
...
...
@@ -80,29 +77,32 @@ namespace Edu.Module.Course
public
bool
SetBatchWebNewsModule
(
List
<
RB_LearningGarden_ViewModel
>
list
)
{
bool
flag
=
false
;
foreach
(
var
model
in
list
)
Task
.
Run
(()
=>
{
if
(
model
.
Id
>
0
)
{
Dictionary
<
string
,
object
>
fileds
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_LearningGarden_ViewModel
.
Title
),
model
.
Title
},
{
nameof
(
RB_LearningGarden_ViewModel
.
Img
),
model
.
Img
},
{
nameof
(
RB_LearningGarden_ViewModel
.
Content
),
model
.
Content
},
{
nameof
(
RB_LearningGarden_ViewModel
.
TypeId
),
model
.
TypeId
},
{
nameof
(
RB_LearningGarden_ViewModel
.
Digest
),
model
.
Digest
},
{
nameof
(
RB_LearningGarden_ViewModel
.
LinkUrl
),
model
.
LinkUrl
},
{
nameof
(
RB_LearningGarden_ViewModel
.
UpdateTime
),
model
.
UpdateTime
}
};
flag
=
learningGardenRepository
.
Update
(
fileds
,
new
WhereHelper
(
nameof
(
RB_LearningGarden_ViewModel
.
Id
),
model
.
Id
));
}
else
foreach
(
var
model
in
list
)
{
var
newId
=
learningGardenRepository
.
Insert
(
model
);
model
.
Id
=
newId
;
flag
=
newId
>
0
;
if
(
model
.
Id
>
0
)
{
Dictionary
<
string
,
object
>
fileds
=
new
Dictionary
<
string
,
object
>()
{
{
nameof
(
RB_LearningGarden_ViewModel
.
Title
),
model
.
Title
},
{
nameof
(
RB_LearningGarden_ViewModel
.
Img
),
model
.
Img
},
{
nameof
(
RB_LearningGarden_ViewModel
.
Content
),
model
.
Content
},
{
nameof
(
RB_LearningGarden_ViewModel
.
TypeId
),
model
.
TypeId
},
{
nameof
(
RB_LearningGarden_ViewModel
.
Digest
),
model
.
Digest
},
{
nameof
(
RB_LearningGarden_ViewModel
.
LinkUrl
),
model
.
LinkUrl
},
{
nameof
(
RB_LearningGarden_ViewModel
.
UpdateTime
),
model
.
UpdateTime
}
};
flag
=
learningGardenRepository
.
Update
(
fileds
,
new
WhereHelper
(
nameof
(
RB_LearningGarden_ViewModel
.
Id
),
model
.
Id
));
}
else
{
var
newId
=
learningGardenRepository
.
Insert
(
model
);
model
.
Id
=
newId
;
flag
=
newId
>
0
;
}
}
}
}
);
return
flag
;
}
...
...
Edu.Repository/LearningGarden/RB_LearningGardenRepository.cs
View file @
9a419340
...
...
@@ -90,5 +90,41 @@ WHERE 1=1
builder
.
AppendFormat
(
" order by a.UpdateTime desc "
);
return
Get
<
RB_LearningGarden_ViewModel
>(
builder
.
ToString
()).
ToList
();
}
/// <summary>
/// 批量新增
/// </summary>
/// <param name="list"></param>
/// <returns></returns>
public
bool
BatchInsertLearningGardenRepository
(
List
<
RB_LearningGarden_ViewModel
>
list
)
{
StringBuilder
builder
=
new
StringBuilder
();
builder
.
Append
(
"INSERT INTO RB_LearningGarden (Title,Img,Content,Digest,LinkUrl,TypeId,Status,CreateDate,CreateBy,Group_Id,School_Id,UpdateTime,WeChatAccountId,Author,GardenType) VALUES"
);
list
.
ForEach
(
x
=>
{
builder
.
Append
(
$"('
{
x
.
Title
}
','
{
x
.
Img
}
','
{
x
.
Content
}
','
{
x
.
Digest
}
','
{
x
.
LinkUrl
}
','
{
x
.
TypeId
}
',
{(
int
)
x
.
Status
}
,'
{
x
.
CreateDate
}
',
{
x
.
CreateBy
}
,
{
x
.
Group_Id
}
,
{
x
.
School_Id
}
,'
{
x
.
UpdateTime
}
','
{
x
.
WeChatAccountId
}
','
{
x
.
Author
}
',
{
x
.
GardenType
}
),"
);
});
builder
=
builder
.
Remove
(
builder
.
Length
-
1
,
1
);
return
base
.
Execute
(
builder
.
ToString
())
>
0
;
}
/// <summary>
/// 批量修改
/// </summary>
/// <param name="list"></param>
/// <returns></returns>
public
bool
BatchUpdateLearningGardenRepository
(
List
<
RB_LearningGarden_ViewModel
>
list
)
{
StringBuilder
builder
=
new
StringBuilder
();
builder
.
Append
(
"INSERT INTO RB_LearningGarden (Id,Title,Img,Content,TypeId,Digest,LinkUrl,UpdateTime) VALUES"
);
list
.
ForEach
(
x
=>
{
builder
.
Append
(
$"(
{
x
.
Id
}
,'
{
x
.
Title
}
','
{
x
.
Img
}
','
{
x
.
Content
}
','
{
x
.
TypeId
}
','
{
x
.
Digest
}
','
{
x
.
LinkUrl
}
','
{
x
.
UpdateTime
}
'),"
);
});
builder
=
builder
.
Remove
(
builder
.
Length
-
1
,
1
);
builder
.
Append
(
"ON DUPLICATE KEY UPDATE Title=VALUES(Title),Img=VALUES(Img),Content=VALUES(Content),TypeId=VALUES(TypeId),Digest=VALUES(Digest),LinkUrl=VALUES(LinkUrl),UpdateTime=VALUES(UpdateTime);"
);
return
Execute
(
builder
.
ToString
())
>
0
;
}
}
}
Edu.WebApi/Controllers/LearningGarden/SchoolGardenController.cs
View file @
9a419340
...
...
@@ -158,7 +158,6 @@ namespace Edu.WebApi.Controllers.LearningGarden
[
HttpPost
]
public
ApiResult
GetGoodsData
()
{
int
pageIndex
=
1
;
int
pageSize
=
20
;
int
pageCount
=
0
;
...
...
@@ -167,18 +166,16 @@ namespace Edu.WebApi.Controllers.LearningGarden
string
token
=
Cache
.
WeChat
.
WeChatReidsCache2
.
GetToken
(
tokenKey
);
if
(
Common
.
Config
.
IsLocal
==
1
)
{
token
=
"
49_j9OOoNVD3jcqJPXX3nb6jalJ9L4AlsltW60JCULR0PikrvW-CYzoFJXK9iS7sK3ygztuf0q5DRGmdJwU7MTqH8tNDtqsMthLHbuiHVVlWIAcycqq24kLKS9K4-FxFMoR-tzLdQOpkYZvDWrEXOFaABAMDU
"
;
token
=
"
53_OVLlSPNJ0hmSrsEUfnJ6kTxFRGxfkcuJJjpBjsDuaSGmtYu95vZNNyh-wIXbFSZ9DtxzFJ1eN0At2QmJ_aWLPFjz4yrz2VrWvmR3KrEQKqfwvxesG82V2WpAgDnxW_tvvWYXRRRX1oguxCtHXSShADAKFF
"
;
}
Common
.
Plugin
.
LogHelper
.
Write
(
"GetGoodsData_Common.Config.IsLocal:"
+
Common
.
Config
.
IsLocal
);
if
(
string
.
IsNullOrEmpty
(
token
))
{
Common
.
Plugin
.
LogHelper
.
Write
(
"GetGoodsData_getToken:key"
+
tokenKey
);
token
=
Common
.
Plugin
.
WeChatHelper
.
GetAccessToken
(
Common
.
Config
.
WeChatAccountAppId
,
Common
.
Config
.
WeChatAccountAppSecret
);
Common
.
Plugin
.
LogHelper
.
Write
(
"GetGoodsData_token:"
+
token
);
Cache
.
WeChat
.
WeChatReidsCache2
.
Set
(
tokenKey
,
token
);
}
var
resultTotalCount
=
HttpHelper
.
HttpGet
(
"https://api.weixin.qq.com/cgi-bin/material/get_materialcount?access_token="
+
token
);
Common
.
Plugin
.
LogHelper
.
Write
(
"GetGoodsData_resultTotalCount:
"
+
resultTotalCount
);
Common
.
Plugin
.
LogHelper
.
Write
Info
(
"GetGoodsData:
"
+
resultTotalCount
);
JObject
parm
=
JObject
.
Parse
(
resultTotalCount
);
List
<
WeChatLearningGardenItem
>
allList
=
new
List
<
WeChatLearningGardenItem
>();
...
...
@@ -194,7 +191,8 @@ namespace Edu.WebApi.Controllers.LearningGarden
}
pageIndex
++;
}
Common
.
Plugin
.
LogHelper
.
WriteInfo
(
"GetGoodsData: "
+
allList
.
Count
());
Common
.
Plugin
.
LogHelper
.
WriteInfo
(
"GetGoodsData: "
+
Common
.
Plugin
.
JsonHelper
.
Serialize
(
allList
));
List
<
RB_LearningGarden_ViewModel
>
learningGardenList
=
new
List
<
RB_LearningGarden_ViewModel
>();
//查询数据库信息
...
...
@@ -208,7 +206,6 @@ namespace Edu.WebApi.Controllers.LearningGarden
{
RB_LearningGarden_ViewModel
extModel
=
new
RB_LearningGarden_ViewModel
()
{
Id
=
0
,
WeChatAccountId
=
item
.
media_id
,
Title
=
itemNews
.
title
,
...
...
@@ -238,7 +235,6 @@ namespace Edu.WebApi.Controllers.LearningGarden
}
learningGardenModule
.
SetBatchWebNewsModule
(
learningGardenList
);
return
ApiResult
.
Success
(
""
);
}
...
...
@@ -265,22 +261,25 @@ namespace Edu.WebApi.Controllers.LearningGarden
}
/// <summary>
/// 获取公众号列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <returns></returns>
static
List
<
WeChatLearningGardenItem
>
GetGoodsList
(
int
pageIndex
,
int
pageSize
)
{
string
tokenKey
=
Cache
.
CacheKey
.
DATA_WeChatAccountToken
+
Common
.
Config
.
WeChatAccountAppId
;
string
token
=
Cache
.
WeChat
.
WeChatReidsCache2
.
GetToken
(
tokenKey
);
if
(
Common
.
Config
.
IsLocal
==
1
)
{
token
=
"
49_j9OOoNVD3jcqJPXX3nb6jalJ9L4AlsltW60JCULR0PikrvW-CYzoFJXK9iS7sK3ygztuf0q5DRGmdJwU7MTqH8tNDtqsMthLHbuiHVVlWIAcycqq24kLKS9K4-FxFMoR-tzLdQOpkYZvDWrEXOFaABAMDU
"
;
token
=
"
53_OVLlSPNJ0hmSrsEUfnJ6kTxFRGxfkcuJJjpBjsDuaSGmtYu95vZNNyh-wIXbFSZ9DtxzFJ1eN0At2QmJ_aWLPFjz4yrz2VrWvmR3KrEQKqfwvxesG82V2WpAgDnxW_tvvWYXRRRX1oguxCtHXSShADAKFF
"
;
}
if
(
string
.
IsNullOrEmpty
(
token
))
{
token
=
Common
.
Plugin
.
WeChatHelper
.
GetAccessToken
(
Common
.
Config
.
WeChatAccountAppId
,
Common
.
Config
.
WeChatAccountAppSecret
);
Cache
.
WeChat
.
WeChatReidsCache2
.
Set
(
tokenKey
,
token
);
}
WeChatLearningGarden
model
=
new
WeChatLearningGarden
();
string
newImaApi
=
"https://api.weixin.qq.com/cgi-bin/material/batchget_material?access_token="
+
token
;
List
<
WeChatLearningGardenItem
>
list
=
new
List
<
WeChatLearningGardenItem
>();
var
resultInfo
=
new
...
...
@@ -290,16 +289,54 @@ namespace Edu.WebApi.Controllers.LearningGarden
count
=
pageSize
};
string
jsonData
=
HttpHelper
.
HttpPost
(
newImaApi
,
JsonHelper
.
Serialize
(
resultInfo
),
""
);
if
(
jsonData
!=
null
&&
!
string
.
IsNullOrEmpty
(
jsonData
))
{
JObject
jObj
=
JObject
.
Parse
(
jsonData
);
var
item
=
jObj
.
GetStringValue
(
"item"
);
list
=
Newtonsoft
.
Json
.
JsonConvert
.
DeserializeObject
<
List
<
WeChatLearningGardenItem
>>(
item
);
//if (model != null && model.item != null)
//{
// list.Add(model.item);
//}
if
(!
string
.
IsNullOrEmpty
(
item
))
{
JArray
jArray
=
JArray
.
Parse
(
item
);
if
(
jArray
!=
null
&&
jArray
.
Count
>
0
)
{
foreach
(
var
jItem
in
jArray
)
{
JObject
sObj
=
JObject
.
Parse
(
jItem
.
ToString
());
JObject
dObj
=
JObject
.
Parse
(
sObj
.
GetStringValue
(
"content"
));
var
newsItem
=
new
List
<
WeChatLearningGardenNewsItem
>();
JArray
subArray
=
JArray
.
Parse
(
dObj
.
GetStringValue
(
"news_item"
));
if
(
subArray
!=
null
&&
subArray
.
Count
>
0
)
{
foreach
(
var
sItem
in
subArray
)
{
var
contentObj
=
JObject
.
Parse
(
sItem
.
ToString
());
newsItem
.
Add
(
new
WeChatLearningGardenNewsItem
()
{
title
=
contentObj
.
GetStringValue
(
"title"
),
author
=
contentObj
.
GetStringValue
(
"author"
),
digest
=
contentObj
.
GetStringValue
(
"digest"
),
content
=
contentObj
.
GetStringValue
(
"content"
),
show_cover_pic
=
contentObj
.
GetInt
(
"show_cover_pic"
),
url
=
contentObj
.
GetStringValue
(
"url"
),
thumb_url
=
contentObj
.
GetStringValue
(
"thumb_url"
),
});
}
}
var
content
=
new
WeChatLearningGardenContent
()
{
news_item
=
newsItem
,
create_time
=
dObj
.
GetLong
(
"create_time"
),
update_time
=
dObj
.
GetLong
(
"update_time"
),
};
WeChatLearningGardenItem
model
=
new
WeChatLearningGardenItem
()
{
media_id
=
sObj
.
GetStringValue
(
"media_id"
),
update_time
=
sObj
.
GetStringValue
(
"update_time"
),
content
=
content
};
list
.
Add
(
model
);
}
}
}
}
return
list
;
}
...
...
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