From d73d859aac7f834561dc1c439930b5f3279d6740 Mon Sep 17 00:00:00 2001 From: Aug <17674666882@163.com> Date: Mon, 28 Jul 2025 17:51:34 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E6=B4=BB=E5=8A=A8=E8=A1=A5=E5=85=85?= =?UTF-8?q?=E6=B4=BB=E5=8A=A8=E6=97=A5=E6=9C=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/CommunityActivity.java | 4 ++ .../communityController/ActivityController.java | 2 +- .../api/service/impl/ActivityServiceImpl.java | 56 ++++++++++++++++++++-- 3 files changed, 58 insertions(+), 4 deletions(-) diff --git a/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/communityActivity/entity/CommunityActivity.java b/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/communityActivity/entity/CommunityActivity.java index 55c422e..b5bb5a8 100644 --- a/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/communityActivity/entity/CommunityActivity.java +++ b/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/modules/communityActivity/entity/CommunityActivity.java @@ -125,4 +125,8 @@ public class CommunityActivity implements Serializable { @TableField(exist = false) int isApply; + //星期几 + @TableField(exist = false) + String dayOfWeek; + } diff --git a/jeecg-boot-module-system/src/main/java/org/jeecg/modules/api/communityController/ActivityController.java b/jeecg-boot-module-system/src/main/java/org/jeecg/modules/api/communityController/ActivityController.java index d61d11e..4f1ed15 100644 --- a/jeecg-boot-module-system/src/main/java/org/jeecg/modules/api/communityController/ActivityController.java +++ b/jeecg-boot-module-system/src/main/java/org/jeecg/modules/api/communityController/ActivityController.java @@ -32,7 +32,7 @@ public class ActivityController { /******************************************************************************************************************/ //获取活动列表 - @ApiOperation(value="活动-获取活动列表", notes="活动-获取活动列表") + @ApiOperation(value="活动-获取活动列表", notes="status:0-当前活动 1-往期活动") @RequestMapping(value = "/queryActivityList", method = {RequestMethod.GET}) public Result queryActivityList(CommunityActivity communityActivity, PageBean pageBean){ return activityService.queryActivityList(communityActivity, pageBean); diff --git a/jeecg-boot-module-system/src/main/java/org/jeecg/modules/api/service/impl/ActivityServiceImpl.java b/jeecg-boot-module-system/src/main/java/org/jeecg/modules/api/service/impl/ActivityServiceImpl.java index f62b506..4da7a3a 100644 --- a/jeecg-boot-module-system/src/main/java/org/jeecg/modules/api/service/impl/ActivityServiceImpl.java +++ b/jeecg-boot-module-system/src/main/java/org/jeecg/modules/api/service/impl/ActivityServiceImpl.java @@ -14,8 +14,6 @@ import org.jeecg.modules.communityActivityApply.entity.CommunityActivityApply; import org.jeecg.modules.communityActivityApply.service.ICommunityActivityApplyService; import org.jeecg.modules.communityActivityCollection.entity.CommunityActivityCollection; import org.jeecg.modules.communityActivityCollection.service.ICommunityActivityCollectionService; -import org.jeecg.modules.communityGoods.entity.CommunityGoods; -import org.jeecg.modules.communityGoodsCollection.entity.CommunityGoodsCollection; import org.jeecg.modules.communityScore.entity.CommunityScore; import org.jeecg.modules.communityScore.service.ICommunityScoreService; import org.jeecg.modules.hanHaiMember.entity.HanHaiMember; @@ -23,6 +21,10 @@ import org.jeecg.modules.hanHaiMember.service.IHanHaiMemberService; import org.springframework.stereotype.Service; import javax.annotation.Resource; +import java.time.DayOfWeek; +import java.time.LocalDate; +import java.util.Calendar; +import java.util.Date; @Service @Slf4j @@ -95,6 +97,12 @@ public class ActivityServiceImpl implements ActivityService { //获取活动信息 pageList = query.page(page); + //判断活动日期是周几 + for (CommunityActivity record : pageList.getRecords()) { + String dayOfWeek = getDay(record.getActivityTime()); + record.setDayOfWeek(dayOfWeek); + } + log.info("活动信息查询结束"); return Result.OK("活动列表", pageList); }catch (Exception e){ @@ -401,7 +409,7 @@ public class ActivityServiceImpl implements ActivityService { CommunityActivity activity = communityActivityService .lambdaQuery() .eq(CommunityActivity::getId, activityId) - .in(CommunityActivity::getStatus, 0, 1) + .in(CommunityActivity::getStatus, 0) .one(); if(null == activity){ log.info("活动不存在或已经结束,请检查活动id:{}", activityId); @@ -451,4 +459,46 @@ public class ActivityServiceImpl implements ActivityService { return Result.error("活动签到失败"); } } + + public String getDay(Date date){ + + String day = "周一"; + // 将用户输入的日期解析为一个Date对象 + Date date1 = date; + + // 创建一个Calendar对象 + Calendar calendar = Calendar.getInstance(); + + // 设置日期 + calendar.setTime(date); + + // 获取星期几 + int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK) - 1; + switch (dayOfWeek){ + case 1: + day = "周一"; + break; + case 2: + day = "周二"; + break; + case 3: + day = "周三"; + break; + case 4: + day = "周四"; + break; + case 5: + day = "周五"; + break; + case 6: + day = "周六"; + break; + case 0: + day = "周日"; + break; + } + + return day; + } + }