Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gxpt_ht
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
pseer
gxpt_ht
Commits
4c1f519d
Commit
4c1f519d
authored
Jul 23, 2024
by
吕明尚
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加查询活动日
parent
0cf41771
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
18 deletions
+38
-18
ActivityController.java
.../java/share/web/controller/system/ActivityController.java
+4
-2
ActivityService.java
...m/src/main/java/share/system/service/ActivityService.java
+3
-1
ActivityServiceImpl.java
...n/java/share/system/service/impl/ActivityServiceImpl.java
+31
-15
No files found.
share-front/src/main/java/share/web/controller/system/ActivityController.java
View file @
4c1f519d
...
...
@@ -13,7 +13,9 @@ import share.system.domain.vo.ActivityDto;
import
share.system.domain.vo.ActivityVo
;
import
share.system.service.ActivityService
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
/**
* 活动Controller
...
...
@@ -39,8 +41,8 @@ public class ActivityController extends BaseController {
@GetMapping
(
"/query"
)
public
AjaxResult
query
(
ActivityDto
dto
)
{
List
<
ActivityVo
>
list
=
activityService
.
queryList
(
dto
);
return
success
(
list
);
Map
<
Date
,
List
<
ActivityVo
>>
map
=
activityService
.
queryList
(
dto
);
return
success
(
map
);
}
...
...
share-system/src/main/java/share/system/service/ActivityService.java
View file @
4c1f519d
...
...
@@ -5,7 +5,9 @@ import share.system.domain.Activity;
import
share.system.domain.vo.ActivityDto
;
import
share.system.domain.vo.ActivityVo
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
/**
* 活动Service接口
...
...
@@ -62,5 +64,5 @@ public interface ActivityService extends IService<Activity> {
*/
public
int
deleteActivityById
(
Long
id
);
List
<
ActivityVo
>
queryList
(
ActivityDto
dto
);
Map
<
Date
,
List
<
ActivityVo
>
>
queryList
(
ActivityDto
dto
);
}
share-system/src/main/java/share/system/service/impl/ActivityServiceImpl.java
View file @
4c1f519d
...
...
@@ -27,8 +27,7 @@ import share.system.service.SConsumerService;
import
java.time.ZoneId
;
import
java.time.ZonedDateTime
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.*
;
import
java.util.stream.Collectors
;
/**
...
...
@@ -120,30 +119,47 @@ public class ActivityServiceImpl extends ServiceImpl<ActivityMapper, Activity> i
}
@Override
public
List
<
ActivityVo
>
queryList
(
ActivityDto
dto
)
{
public
Map
<
Date
,
List
<
ActivityVo
>
>
queryList
(
ActivityDto
dto
)
{
SConsumer
user
=
sConsumerService
.
getInfo
();
if
(
ObjectUtil
.
isEmpty
(
user
))
{
return
new
HashMap
<>();
}
ConsumerMember
consumerMember
=
consumerMemberService
.
getOne
(
new
LambdaQueryWrapper
<
ConsumerMember
>()
.
eq
(
ConsumerMember:
:
getConsumerId
,
user
.
getId
())
);
if
(
ObjectUtil
.
isEmpty
(
consumerMember
))
{
return
new
ArrayList
<>();
return
new
HashMap
<>();
}
List
<
Date
>
days
=
new
ArrayList
<>();
//从当前的日期开始,加4天
for
(
int
i
=
0
;
i
<=
4
;
i
++)
{
days
.
add
(
DateUtils
.
addDays
(
new
Date
(),
i
));
}
Activity
activity
=
new
Activity
();
BeanUtils
.
copyProperties
(
dto
,
activity
);
List
<
Activity
>
activities
=
selectActivityList
(
activity
);
CronParser
cronParser
=
new
CronParser
(
CronDefinitionBuilder
.
instanceDefinitionFor
(
CronType
.
QUARTZ
));
List
<
ActivityVo
>
voList
=
new
ArrayList
<>();
activities
.
stream
().
forEach
(
item
->
{
Cron
cron
=
cronParser
.
parse
(
item
.
getCronExpression
());
ExecutionTime
executionTime
=
ExecutionTime
.
forCron
(
cron
);
boolean
match
=
executionTime
.
isMatch
(
ZonedDateTime
.
ofInstant
(
dto
.
getDay
().
toInstant
(),
ZoneId
.
systemDefault
()));
if
(
match
&&
consumerMember
.
getMemberType
().
equals
(
item
.
getMemberType
()))
{
ActivityVo
activityVo
=
new
ActivityVo
();
BeanUtils
.
copyProperties
(
item
,
activityVo
);
voList
.
add
(
activityVo
);
Map
<
Date
,
List
<
ActivityVo
>>
map
=
new
HashMap
<>();
days
.
stream
().
forEach
(
day
->
{
List
<
ActivityVo
>
voList
=
new
ArrayList
<>();
activities
.
stream
().
forEach
(
item
->
{
Cron
cron
=
cronParser
.
parse
(
item
.
getCronExpression
());
ExecutionTime
executionTime
=
ExecutionTime
.
forCron
(
cron
);
boolean
match
=
executionTime
.
isMatch
(
ZonedDateTime
.
ofInstant
(
day
.
toInstant
(),
ZoneId
.
systemDefault
()));
if
(
match
&&
consumerMember
.
getMemberType
().
equals
(
item
.
getMemberType
()))
{
ActivityVo
activityVo
=
new
ActivityVo
();
BeanUtils
.
copyProperties
(
item
,
activityVo
);
voList
.
add
(
activityVo
);
}
});
if
(
voList
.
size
()
>
0
)
{
map
.
put
(
day
,
voList
);
}
else
{
map
.
put
(
day
,
new
ArrayList
<>());
}
});
return
voList
;
return
map
;
}
}
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