From 40d3bb9fe638a0bd79e829e7fd5114871101390b Mon Sep 17 00:00:00 2001
From: peng <peng.com>
Date: 星期四, 20 十一月 2025 10:52:38 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/user_action' into user_action
---
framework/src/main/java/cn/lili/modules/lmk/service/impl/MyActivityServiceImpl.java | 131 +++++++++++++++++++++++++++++++++++++------
1 files changed, 113 insertions(+), 18 deletions(-)
diff --git a/framework/src/main/java/cn/lili/modules/lmk/service/impl/MyActivityServiceImpl.java b/framework/src/main/java/cn/lili/modules/lmk/service/impl/MyActivityServiceImpl.java
index 8193824..03a8c80 100644
--- a/framework/src/main/java/cn/lili/modules/lmk/service/impl/MyActivityServiceImpl.java
+++ b/framework/src/main/java/cn/lili/modules/lmk/service/impl/MyActivityServiceImpl.java
@@ -1,18 +1,28 @@
package cn.lili.modules.lmk.service.impl;
import cn.lili.base.Result;
+import cn.lili.common.enums.ActivityCoverTypeEnum;
+import cn.lili.common.security.context.UserContext;
import cn.lili.modules.lmk.domain.entity.Activity;
-import cn.lili.modules.lmk.domain.query.ActivityReportQuery;
+import cn.lili.modules.lmk.domain.entity.ActivityReport;
+import cn.lili.modules.lmk.domain.entity.MyCollect;
+import cn.lili.modules.lmk.domain.form.ActivityReportForm;
import cn.lili.modules.lmk.domain.query.MyActivityQuery;
import cn.lili.modules.lmk.domain.vo.ActivityReportVO;
import cn.lili.modules.lmk.domain.vo.ActivityVO;
import cn.lili.modules.lmk.domain.vo.MyActivityVo;
import cn.lili.modules.lmk.mapper.ActivityMapper;
-import cn.lili.modules.lmk.service.LmkFileService;
+import cn.lili.modules.lmk.mapper.ActivityReportMapper;
+import cn.lili.modules.lmk.mapper.MyCollectMapper;
+import cn.lili.modules.lmk.service.ActivityReportService;
import cn.lili.modules.lmk.service.MyActivityService;
+import cn.lili.utils.COSUtil;
+import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
+import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
+import org.springframework.util.Assert;
import java.util.Date;
import java.util.List;
@@ -21,44 +31,129 @@
@RequiredArgsConstructor
public class MyActivityServiceImpl extends ServiceImpl<ActivityMapper, Activity> implements MyActivityService {
private final ActivityMapper activityMapper;
- private final LmkFileService lmkFileService;
+
+ private final ActivityReportMapper activityReportMapper;
+ private final COSUtil cOSUtil;
+ private final MyCollectMapper myCollectMapper;
@Override
public Result getMyActivityList(MyActivityQuery query) {
- List<MyActivityVo> myActivityList = activityMapper.getMyActivityList(query);
-
- for (MyActivityVo vo : myActivityList) {
- System.out.println(vo);
- if (!"鏂囧瓧".equals(vo.getCoverType())){
-// String url = lmkFileService.getPreviewUrl(vo.getCover());
-// vo.setUrl(url);
+ String userId = UserContext.getCurrentUserId();
+ List<MyActivityVo> myActivityList = activityMapper.getMyActivityList(query,userId);
+ for (MyActivityVo myActivityVo : myActivityList){
+ if (!ActivityCoverTypeEnum.TEXT.getType().equals(myActivityVo.getCoverType())){
+ myActivityVo.setUrl(cOSUtil.getPreviewUrl(myActivityVo.getCover()));
}
}
return Result.ok().data(myActivityList);
}
@Override
- public Result cancelActivity(ActivityReportQuery query) {
+ public Result activityCancel(String activityId) {
// TODO 鍒ゆ柇鏄惁鍦ㄦ姤鍚嶆椂闂村唴 鍦ㄧ殑璇濆彲浠ュ彇娑堟姤鍚嶏紝 锛堣嫢鏈夋姤鍚嶈垂闇�瑕侀��娆撅級
- ActivityReportVO vo = activityMapper.getActivityReport(query);
+ //鑾峰緱涓棿琛ㄤ俊鎭�
+ ActivityReportVO vo = userReport(activityId);
- Activity activity = activityMapper.selectById(vo.getActivityId());
+ Activity activity = activityMapper.selectById(activityId);
Date date = new Date();
if(!date.before(activity.getReportStartTime()) && !date.after(activity.getReportEndTime())){
- int affectedRows = activityMapper.cancelActivity(vo.getId());
- if (affectedRows > 0) {
+ boolean rowsAffected = new LambdaUpdateChainWrapper<ActivityReport>(activityReportMapper)
+ .eq(ActivityReport::getId, vo.getId()) // WHERE id = ?
+ .set(ActivityReport::getCancel, true) // SET cancel = true
+ .update(); // 鎵ц鏇存柊
+
+
+ if (rowsAffected) {
return Result.ok("娲诲姩鍙栨秷鎴愬姛");
} else {
// 鍙�夛細璁板綍璀﹀憡鏃ュ織
- throw new RuntimeException("娲诲姩涓嶅瓨鍦ㄦ垨宸插彇娑�");
+ return Result.error("娲诲姩涓嶅瓨鍦ㄦ垨宸插彇娑�");
}
}else {
- throw new RuntimeException("娲诲姩宸蹭笉鍦ㄦ姤鍚嶆椂闂村唴鏃犳硶鍙栨秷");
+ return Result.error("娲诲姩宸蹭笉鍦ㄦ姤鍚嶆椂闂村唴鏃犳硶鍙栨秷");
+ }
+ }
+
+ @Override
+ public Result activityReport(ActivityReportForm reportActivityForm) {
+ //鍒ゆ柇鐢ㄦ埛鏄惁宸茬粡鎶ュ悕璇ユ椿鍔�
+ ActivityReportVO reportVO = userReport(reportActivityForm.getActivityId());
+ if (reportVO != null) {
+ //鍒ゆ柇鏄惁宸插彇娑堣繃璇ユ椿鍔�
+ if (reportVO.getCancel()){
+ //閲嶆柊鎶ュ悕
+
+ ActivityReport entity = ActivityReportForm.getEntityByForm(reportActivityForm, null);
+ entity.setId(reportVO.getId());
+ entity.setUserId(UserContext.getCurrentUserId());
+ entity.setCancel(false);
+ activityReportMapper.updateById(entity);
+ return Result.ok("鎴愬姛");
+ }else {
+ return Result.error("璇ユ椿鍔ㄥ凡鎶ュ悕");
+ }
+
+
+ }
+ ActivityReport entity = ActivityReportForm.getEntityByForm(reportActivityForm, null);
+ entity.setUserId(UserContext.getCurrentUserId());
+ activityReportMapper.insert(entity);
+ return Result.ok("鎴愬姛");
+ }
+
+ /**
+ * 鑾峰緱涓棿琛ㄤ俊鎭�氳繃activityId锛寀serId
+ * @param activityId 娲诲姩id
+ * @return
+ */
+ @Override
+ public ActivityReportVO userReport(String activityId){
+ if (UserContext.getCurrentUserId() == null || UserContext.getCurrentUserId().isEmpty()){
+ throw new RuntimeException("鐢ㄦ埛鐧诲綍鐘舵�佸紓甯�");
+ }
+ return activityReportMapper.getActivityReport(activityId,UserContext.getCurrentUserId());
+ }
+
+ /**鑾峰緱娲诲姩璇︽儏 骞� 娲诲姩璐﹀彿鎶ュ悕娲诲姩鎯呭喌锛屾敹钘忔儏鍐�
+ *
+ * @param activityId
+ * @return
+ */
+ @Override
+ public Result detailByUsr(String activityId) {
+ //鏌ヨ娲诲姩璇︽儏
+ ActivityVO vo = baseMapper.getById(activityId);
+ Assert.notNull(vo, "璁板綍涓嶅瓨鍦�");
+ //鏌ヨ鎶ュ悕鎯呭喌
+ ActivityReportVO reportVO = userReport(activityId);
+ //鏌ヨ鐢ㄦ埛鏀惰棌鎯呭喌
+ MyCollect myCollect = new LambdaQueryChainWrapper<>(myCollectMapper)
+ .eq(MyCollect::getRefId,activityId)
+ .eq(MyCollect::getUserId,UserContext.getCurrentUserId())
+ .eq(MyCollect::getDeleteFlag,false)
+ .one();
+ vo.setIsCollect(myCollect != null);
+ if (!ActivityCoverTypeEnum.TEXT.getType().equals(vo.getCoverType())){
+ vo.setUrl(cOSUtil.getPreviewUrl(vo.getCover()));
}
+ //鍒欏綋鍓嶇敤鎴锋湭鎶ュ悕
+ if (reportVO == null){
+ vo.setIsReport(false);
+ }else {
+ //宸插彇娑堝垯鍙互鎶ュ悕
+ if (reportVO.getCancel()){
+ vo.setIsReport(false);
+ }else {
+ vo.setIsReport(true);
+ }
-
+ }
+ return Result.ok().data(vo);
}
+
+
+
}
--
Gitblit v1.8.0