|
|
@@ -7,7 +7,9 @@ import com.etotem.cfc.entity.Activity;
|
|
|
import com.etotem.cfc.mapper.ActivityMapper;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
|
|
|
@@ -24,13 +26,14 @@ public class ActivityAdminService {
|
|
|
|
|
|
/**
|
|
|
* 分页查询活动列表(包含草稿)
|
|
|
- * 支持按 status / dimensionCode 过滤
|
|
|
+ * 支持按 status / dimensionCode / auditStatus 过滤
|
|
|
*/
|
|
|
public Result<Map<String, Object>> list(Map<String, Object> params) {
|
|
|
int page = params.get("page") != null ? ((Number) params.get("page")).intValue() : 1;
|
|
|
int size = params.get("size") != null ? ((Number) params.get("size")).intValue() : 20;
|
|
|
String status = (String) params.get("status");
|
|
|
String dimensionCode = (String) params.get("dimensionCode");
|
|
|
+ String auditStatus = (String) params.get("auditStatus");
|
|
|
|
|
|
LambdaQueryWrapper<Activity> wrapper = new LambdaQueryWrapper<>();
|
|
|
if (status != null && !status.isEmpty()) {
|
|
|
@@ -39,6 +42,9 @@ public class ActivityAdminService {
|
|
|
if (dimensionCode != null && !dimensionCode.isEmpty()) {
|
|
|
wrapper.eq(Activity::getDimensionCode, dimensionCode);
|
|
|
}
|
|
|
+ if (auditStatus != null && !auditStatus.isEmpty()) {
|
|
|
+ wrapper.eq(Activity::getAuditStatus, auditStatus);
|
|
|
+ }
|
|
|
wrapper.orderByDesc(Activity::getUpdatedAt);
|
|
|
|
|
|
Page<Activity> pageResult = activityMapper.selectPage(new Page<>(page, size), wrapper);
|
|
|
@@ -85,4 +91,73 @@ public class ActivityAdminService {
|
|
|
return Result.error("无效的action");
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ @Transactional
|
|
|
+ public void submitForReview(Long id) {
|
|
|
+ Activity activity = activityMapper.selectById(id);
|
|
|
+ if (activity == null) {
|
|
|
+ throw new RuntimeException("活动不存在");
|
|
|
+ }
|
|
|
+ if (!"draft".equals(activity.getStatus())) {
|
|
|
+ throw new RuntimeException("仅草稿状态可提交审核");
|
|
|
+ }
|
|
|
+ activity.setStatus("pending");
|
|
|
+ activity.setAuditStatus("pending");
|
|
|
+ activityMapper.updateById(activity);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Transactional
|
|
|
+ public void auditActivity(Long id, String action, String auditReason, Long adminId) {
|
|
|
+ Activity activity = activityMapper.selectById(id);
|
|
|
+ if (activity == null) {
|
|
|
+ throw new RuntimeException("活动不存在");
|
|
|
+ }
|
|
|
+ if (!"pending".equals(activity.getStatus())) {
|
|
|
+ throw new RuntimeException("仅待审核状态可审核");
|
|
|
+ }
|
|
|
+ if (!"approved".equals(action) && !"rejected".equals(action)) {
|
|
|
+ throw new RuntimeException("审核操作无效");
|
|
|
+ }
|
|
|
+ if ("approved".equals(action)) {
|
|
|
+ activity.setStatus("published");
|
|
|
+ activity.setAuditStatus("approved");
|
|
|
+ } else {
|
|
|
+ activity.setStatus("rejected");
|
|
|
+ activity.setAuditStatus("rejected");
|
|
|
+ activity.setAuditReason(auditReason);
|
|
|
+ activity.setAuditorId(adminId);
|
|
|
+ activity.setAuditedAt(new Date());
|
|
|
+ }
|
|
|
+ activityMapper.updateById(activity);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Transactional
|
|
|
+ public void withdraw(Long id) {
|
|
|
+ Activity activity = activityMapper.selectById(id);
|
|
|
+ if (activity == null) {
|
|
|
+ throw new RuntimeException("活动不存在");
|
|
|
+ }
|
|
|
+ if (!"published".equals(activity.getStatus())) {
|
|
|
+ throw new RuntimeException("仅发布中的活动可撤回");
|
|
|
+ }
|
|
|
+ activity.setStatus("withdrawn");
|
|
|
+ activityMapper.updateById(activity);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Transactional
|
|
|
+ public void reDraft(Long id) {
|
|
|
+ Activity activity = activityMapper.selectById(id);
|
|
|
+ if (activity == null) {
|
|
|
+ throw new RuntimeException("活动不存在");
|
|
|
+ }
|
|
|
+ if (!"rejected".equals(activity.getStatus())) {
|
|
|
+ throw new RuntimeException("仅已驳回的活动可重新编辑");
|
|
|
+ }
|
|
|
+ activity.setStatus("draft");
|
|
|
+ activity.setAuditStatus(null);
|
|
|
+ activity.setAuditReason(null);
|
|
|
+ activity.setAuditorId(null);
|
|
|
+ activity.setAuditedAt(null);
|
|
|
+ activityMapper.updateById(activity);
|
|
|
+ }
|
|
|
}
|