xgb 1 місяць тому
батько
коміт
dbec03053e

+ 16 - 0
fs-admin/src/main/java/com/fs/app/task/ActivityTask.java

@@ -0,0 +1,16 @@
+package com.fs.app.task;
+
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
+
+/**
+ * @description: TODO
+ * @author: Xgb
+ * @createDate: 2026/3/10
+ * @version: 1.0
+ */
+@Component("activityTask")
+@Slf4j
+public class ActivityTask {
+    // 定时
+}

+ 3 - 1
fs-service/src/main/java/com/fs/activity/domain/AccActivity.java

@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import java.util.Date;
+
+import com.fs.common.core.domain.BaseEntity;
 import lombok.Data;
 
 /**
@@ -12,7 +14,7 @@ import lombok.Data;
  */
 @TableName(value ="acc_activity")
 @Data
-public class AccActivity {
+public class AccActivity extends BaseEntity {
     /**
      * 主键ID
      */

+ 8 - 76
fs-service/src/main/java/com/fs/activity/domain/AccWork.java

@@ -1,9 +1,13 @@
 package com.fs.activity.domain;
 
 import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import java.util.Date;
+import java.util.Map;
+
+import com.fs.common.core.domain.BaseEntity;
 import lombok.Data;
 
 /**
@@ -12,7 +16,7 @@ import lombok.Data;
  */
 @TableName(value ="acc_work")
 @Data
-public class AccWork {
+public class AccWork  {
     /**
      * 主键ID
      */
@@ -89,79 +93,7 @@ public class AccWork {
      */
     private Date updatedAt;
 
-    @Override
-    public boolean equals(Object that) {
-        if (this == that) {
-            return true;
-        }
-        if (that == null) {
-            return false;
-        }
-        if (getClass() != that.getClass()) {
-            return false;
-        }
-        AccWork other = (AccWork) that;
-        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
-            && (this.getTeamId() == null ? other.getTeamId() == null : this.getTeamId().equals(other.getTeamId()))
-            && (this.getActivityId() == null ? other.getActivityId() == null : this.getActivityId().equals(other.getActivityId()))
-            && (this.getWorkName() == null ? other.getWorkName() == null : this.getWorkName().equals(other.getWorkName()))
-            && (this.getCoverUrl() == null ? other.getCoverUrl() == null : this.getCoverUrl().equals(other.getCoverUrl()))
-            && (this.getVideoUrl() == null ? other.getVideoUrl() == null : this.getVideoUrl().equals(other.getVideoUrl()))
-            && (this.getDescription() == null ? other.getDescription() == null : this.getDescription().equals(other.getDescription()))
-            && (this.getDuration() == null ? other.getDuration() == null : this.getDuration().equals(other.getDuration()))
-            && (this.getVoteCount() == null ? other.getVoteCount() == null : this.getVoteCount().equals(other.getVoteCount()))
-            && (this.getViewCount() == null ? other.getViewCount() == null : this.getViewCount().equals(other.getViewCount()))
-            && (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus()))
-            && (this.getAuditRemark() == null ? other.getAuditRemark() == null : this.getAuditRemark().equals(other.getAuditRemark()))
-            && (this.getAuditTime() == null ? other.getAuditTime() == null : this.getAuditTime().equals(other.getAuditTime()))
-            && (this.getCreatedAt() == null ? other.getCreatedAt() == null : this.getCreatedAt().equals(other.getCreatedAt()))
-            && (this.getUpdatedAt() == null ? other.getUpdatedAt() == null : this.getUpdatedAt().equals(other.getUpdatedAt()));
-    }
-
-    @Override
-    public int hashCode() {
-        final int prime = 31;
-        int result = 1;
-        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
-        result = prime * result + ((getTeamId() == null) ? 0 : getTeamId().hashCode());
-        result = prime * result + ((getActivityId() == null) ? 0 : getActivityId().hashCode());
-        result = prime * result + ((getWorkName() == null) ? 0 : getWorkName().hashCode());
-        result = prime * result + ((getCoverUrl() == null) ? 0 : getCoverUrl().hashCode());
-        result = prime * result + ((getVideoUrl() == null) ? 0 : getVideoUrl().hashCode());
-        result = prime * result + ((getDescription() == null) ? 0 : getDescription().hashCode());
-        result = prime * result + ((getDuration() == null) ? 0 : getDuration().hashCode());
-        result = prime * result + ((getVoteCount() == null) ? 0 : getVoteCount().hashCode());
-        result = prime * result + ((getViewCount() == null) ? 0 : getViewCount().hashCode());
-        result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode());
-        result = prime * result + ((getAuditRemark() == null) ? 0 : getAuditRemark().hashCode());
-        result = prime * result + ((getAuditTime() == null) ? 0 : getAuditTime().hashCode());
-        result = prime * result + ((getCreatedAt() == null) ? 0 : getCreatedAt().hashCode());
-        result = prime * result + ((getUpdatedAt() == null) ? 0 : getUpdatedAt().hashCode());
-        return result;
-    }
-
-    @Override
-    public String toString() {
-        StringBuilder sb = new StringBuilder();
-        sb.append(getClass().getSimpleName());
-        sb.append(" [");
-        sb.append("Hash = ").append(hashCode());
-        sb.append(", id=").append(id);
-        sb.append(", teamId=").append(teamId);
-        sb.append(", activityId=").append(activityId);
-        sb.append(", workName=").append(workName);
-        sb.append(", coverUrl=").append(coverUrl);
-        sb.append(", videoUrl=").append(videoUrl);
-        sb.append(", description=").append(description);
-        sb.append(", duration=").append(duration);
-        sb.append(", voteCount=").append(voteCount);
-        sb.append(", viewCount=").append(viewCount);
-        sb.append(", status=").append(status);
-        sb.append(", auditRemark=").append(auditRemark);
-        sb.append(", auditTime=").append(auditTime);
-        sb.append(", createdAt=").append(createdAt);
-        sb.append(", updatedAt=").append(updatedAt);
-        sb.append("]");
-        return sb.toString();
-    }
+    @TableField(exist = false)
+    private Map<String, Object> params;
+
 }

+ 2 - 2
fs-service/src/main/java/com/fs/activity/mapper/AccTeamMapper.java

@@ -12,9 +12,9 @@ import org.apache.ibatis.annotations.Param;
 */
 public interface AccTeamMapper extends BaseMapper<AccTeam> {
 
-    AccTeam isSignUp(@Param("userId") long userId,@Param("activityId") Long activityId);
+    AccTeam isSignUp(@Param("userId") Long userId,@Param("activityId") Long activityId);
 
-    AccTeam selectTeamByUserIdAndActivityId(Long userId, Long activityId);
+    AccTeam selectTeamByUserIdAndActivityId(@Param("userId") Long userId,@Param("activityId") Long activityId);
 }
 
 

+ 3 - 0
fs-service/src/main/java/com/fs/activity/mapper/AccWorkMapper.java

@@ -2,6 +2,7 @@ package com.fs.activity.mapper;
 
 import com.fs.activity.domain.AccWork;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -60,6 +61,8 @@ public interface AccWorkMapper extends BaseMapper<AccWork> {
      * @return 结果
      */
     int deleteAccWorkByIds(Long[] ids);
+
+    AccWork selectOneByTeamIdAndActivityId(@Param("activityId") Long activityId,@Param("teamId") Long teamId);
 }
 
 

+ 3 - 2
fs-service/src/main/java/com/fs/activity/service/impl/AccTeamServiceImpl.java

@@ -63,12 +63,13 @@ public class AccTeamServiceImpl extends ServiceImpl<AccTeamMapper, AccTeam>
     @Transactional
     public R signUpLeader(AccTeam accTeam) {
 
-        accTeam.setTeamCode(CodeGenerator.generateTeamCode(accTeam.getActivityId()));
+
         R r=accActivityService.checkActivitySignUpStatus(accTeam.getActivityId());
         if(!r.get("code").equals(200)){
             return r;
         }
 
+        accTeam.setTeamCode(CodeGenerator.generateTeamCode(accTeam.getActivityId()));
         accTeam.setMemberCount(1);
         if(baseMapper.insert(accTeam)<=0){
             return R.error("创建领队失败");
@@ -82,7 +83,7 @@ public class AccTeamServiceImpl extends ServiceImpl<AccTeamMapper, AccTeam>
         if(accTeamMemberMapper.insert(accTeamMember)<=0){
             throw new RuntimeException("创建队员失败");
         }
-        return R.ok();
+        return R.ok().put("data",accTeam);
     }
 
     /**

+ 16 - 23
fs-service/src/main/java/com/fs/activity/service/impl/AccWorkServiceImpl.java

@@ -2,6 +2,7 @@ package com.fs.activity.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fs.activity.domain.AccVoteRecord;
 import com.fs.activity.domain.AccWork;
@@ -153,9 +154,7 @@ public class AccWorkServiceImpl extends ServiceImpl<AccWorkMapper, AccWork>
         }
 
         // 查询是否上传了视频,已上传更新
-        AccWork work = baseMapper.selectOne(new LambdaQueryWrapper<AccWork>()
-                .eq(AccWork::getActivityId, accWork.getActivityId())
-                .eq(AccWork::getTeamId, accWork.getTeamId()));
+        AccWork work=baseMapper.selectOneByTeamIdAndActivityId(accWork.getActivityId(),accWork.getTeamId());
         if(work!=null){
             accWork.setId(work.getId());
             if (baseMapper.updateById(accWork)<1){
@@ -200,11 +199,6 @@ public class AccWorkServiceImpl extends ServiceImpl<AccWorkMapper, AccWork>
 
         // 4. 使用Redis分布式锁防止重复提交
         String lockKey = VOTE_LOCK_KEY + userId + ":" + workId + ":" + todayStr;
-        Boolean locked = redisTemplate.opsForValue().setIfAbsent(lockKey, "1", 10, TimeUnit.SECONDS);
-        if (Boolean.FALSE.equals(locked)) {
-            throw new ServiceException("请勿重复提交");
-        }
-
         // 引入 Redisson
         RLock lock = redissonClient.getLock(lockKey);
         boolean lockAcquired = false;
@@ -220,7 +214,7 @@ public class AccWorkServiceImpl extends ServiceImpl<AccWorkMapper, AccWork>
                     throw new ServiceException("今日已给该作品投票");
                 }
 
-                // 6. 创建投票记录
+                // 6. 创建投票记录 不加事务,影响速度 数据不对后期家定时任务修复
                 AccVoteRecord record = new AccVoteRecord();
                 record.setWorkId(workId);
                 record.setUserId(userId);
@@ -230,34 +224,33 @@ public class AccWorkServiceImpl extends ServiceImpl<AccWorkMapper, AccWork>
                     throw new ServiceException("投票失败");
                 }
 
-                AccWork work = new AccWork();
-                work.setId(workId);
-                // 7. 更新作品票数
-                work.setVoteCount(work.getVoteCount() + 1);
-                baseMapper.updateById(work);
-
                 // 8. 更新Redis缓存
                 // 8.1 更新作品票数缓存
                 String countKey = VOTE_COUNT_KEY + workId;
-                redisTemplate.opsForValue().increment(countKey);
+                Long currentVotes=redisTemplate.opsForValue().increment(countKey);
+
+
+                UpdateWrapper<AccWork> updateWrapper = new UpdateWrapper<>();
+                updateWrapper.eq("id", workId).setSql("vote_count = vote_count + 1");
+                if(baseMapper.update(null, updateWrapper)<1){
+                    throw new ServiceException("更新失败");
+                }
+
 
                 // 8.2 更新排行榜(使用ZSet)
-                redisTemplate.opsForZSet().incrementScore(VOTE_RANKING_KEY, String.valueOf(workId), 1);
+//                redisTemplate.opsForZSet().incrementScore(VOTE_RANKING_KEY, String.valueOf(workId), 1);
 
 
                 // 8.4 更新用户今日投票计数
                 String dailyLimitKey = DAILY_VOTE_LIMIT + activityId +":"+ userId + ":" + todayStr;
-                Long currentVotes = redisTemplate.opsForValue().increment(dailyLimitKey);
-                redisTemplate.expire(dailyLimitKey, 2, TimeUnit.DAYS);
+                redisTemplate.opsForValue().increment(dailyLimitKey);
+                redisTemplate.expire(dailyLimitKey, 1, TimeUnit.DAYS);
 
-                log.info("用户{}给作品{}投票成功,今日第{}票,当前作品总票数:{}",
-                        userId, workId, currentVotes, work.getVoteCount());
 
                 // 9. 返回结果
                 AccVoteRecordResponse response = new AccVoteRecordResponse();
                 response.setWorkId(workId);
-                response.setWorkName(work.getWorkName());
-                response.setCurrentVotes(work.getVoteCount());
+                response.setCurrentVotes(currentVotes);
                 return R.ok().put("data", response);
             }else {
                 throw new ServiceException("服务繁忙,请稍后再试");

+ 4 - 0
fs-service/src/main/resources/mapper/activity/AccWorkMapper.xml

@@ -49,6 +49,10 @@
         where id = #{id}
     </select>
 
+    <select id="selectOneByTeamIdAndActivityId" resultType="com.fs.activity.domain.AccWork">
+        <include refid="selectAccWorkVo"/> where team_id = #{teamId} and activity_id = #{activityId}
+    </select>
+
     <insert id="insertAccWork" parameterType="AccWork" useGeneratedKeys="true" keyProperty="id">
         insert into acc_work
         <trim prefix="(" suffix=")" suffixOverrides=",">

+ 4 - 8
fs-user-app/src/main/java/com/fs/app/controller/app/AccActivityController.java

@@ -1,7 +1,6 @@
 package com.fs.app.controller.app;
 
 import com.fs.activity.domain.AccTeam;
-import com.fs.activity.domain.AccVoteRecord;
 import com.fs.activity.domain.AccWork;
 import com.fs.activity.param.AccTeamMemberRequest;
 import com.fs.activity.param.AccVoteRecordRequest;
@@ -9,13 +8,9 @@ import com.fs.activity.service.AccActivityService;
 import com.fs.activity.service.AccTeamMemberService;
 import com.fs.activity.service.AccTeamService;
 import com.fs.activity.service.AccWorkService;
-import com.fs.activity.service.impl.AccTeamMemberServiceImpl;
 import com.fs.app.annotation.Login;
 import com.fs.app.controller.AppBaseController;
 import com.fs.common.core.domain.R;
-import com.fs.course.domain.FsUserTalent;
-import com.fs.course.param.FsUserVideoAddParam;
-import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
@@ -52,8 +47,8 @@ public class AccActivityController extends AppBaseController
      */
     @Login
     @GetMapping("/isSignUp")
-    public Boolean isSignUp(Long activityId){
-        return accTeamService.isSignUp(Long.parseLong(getUserId()),activityId);
+    public R isSignUp(Long activityId){
+        return  R.ok().put("isSignUp",accTeamService.isSignUp(Long.parseLong(getUserId()),activityId));
     }
 
     /**
@@ -79,6 +74,7 @@ public class AccActivityController extends AppBaseController
     @Login
     @PostMapping("/signUpLeader")
     public R signUpLeader(@RequestBody AccTeam accTeam){
+        accTeam.setLeaderId(Long.parseLong(getUserId()));
         return accTeamService.signUpLeader(accTeam);
     }
 
@@ -149,7 +145,7 @@ public class AccActivityController extends AppBaseController
      */
     @Login
     @PostMapping("/uploadVideo")
-    public R talentVideo(@RequestBody AccWork accWork){
+    public R uploadVideo(@RequestBody AccWork accWork){
         return accWorkService.uploadVideo(accWork);
     }