Parcourir la source

评测曲目增加评测难度

Eric il y a 2 ans
Parent
commit
10fa8f74fd

+ 32 - 0
cooleshow-user/user-admin/src/main/java/com/yonge/cooleshow/admin/controller/ActivityEvaluationController.java

@@ -23,6 +23,8 @@ import com.yonge.toolset.mybatis.support.PageUtil;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
+import org.apache.commons.collections.CollectionUtils;
+import org.joda.time.DateTime;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpStatus;
 import org.springframework.security.access.prepost.PreAuthorize;
@@ -36,6 +38,7 @@ import javax.annotation.Resource;
 import javax.validation.Valid;
 import java.util.List;
 import java.util.Objects;
+import java.util.Optional;
 
 @RestController
 @RequestMapping("/activityEvaluation")
@@ -80,6 +83,35 @@ public class ActivityEvaluationController extends BaseController {
     	return status(activityEvaluationService.addBatch(param,user));
 	}
 
+	@ApiOperation(value = "批量更新曲目信息")
+	@PostMapping("/batchUpdate")
+	public HttpResponseResult<Boolean> batchUpdateEvaluationInfo(ActivityEvaluationDto info) {
+
+		SysUser user = sysUserFeignService.queryUserInfo();
+		if (user == null || null == user.getId()) {
+			return failed(HttpStatus.FORBIDDEN, "请登录");
+		}
+
+		if (CollectionUtils.isEmpty(info.getEvaluationInfos())) {
+			return failed("评测曲目信息为空");
+		}
+
+		for (ActivityEvaluationDto.EvaluationInfo item : info.getEvaluationInfos()) {
+
+			if (Objects.isNull(item.getId())
+					|| Objects.isNull(item.getEvaluationDifficulty())) {
+				return failed("无效的请求参数");
+			}
+
+			item.updateBy(user.getId()).updateTime(DateTime.now().toDate());
+		}
+
+		// 批量更新曲目信息
+		int ret = activityEvaluationService.batchUpdateEvaluationInfo(user, info);
+
+		return status(ret > 0);
+	}
+
  	/**
 	 * 删除
 	 */

+ 48 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dto/ActivityEvaluationDto.java

@@ -1,10 +1,17 @@
 package com.yonge.cooleshow.biz.dal.dto;
 
 import com.yonge.cooleshow.common.entity.BaseEntity;
+import com.yonge.cooleshow.common.enums.HardLevelEnum;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
 
 import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+import java.util.Date;
+import java.util.List;
 
 /**
  * @Author: liweifan
@@ -17,12 +24,16 @@ public class ActivityEvaluationDto extends BaseEntity {
 	@ApiModelProperty("活动id ")
 	@NotNull(message = "活动id不能为空")
 	private Long activityId;
+
 	@ApiModelProperty("曲目id 多个用,分割 ")
 	//@NotBlank(message = "曲子id不能为空")
 	private String musicSheetIds; // 评测活动曲目ID
 	@ApiModelProperty("活动老师id 多个用,分割 ")
 	private String teacherIds; // 分享活动老师ID
 
+	@ApiModelProperty("评测内空 ")
+	private List<EvaluationInfo> evaluationInfos;
+
 	public String getTeacherIds() {
 		return teacherIds;
 	}
@@ -47,4 +58,41 @@ public class ActivityEvaluationDto extends BaseEntity {
 	public void setMusicSheetIds(String musicSheetIds) {
 		this.musicSheetIds = musicSheetIds;
 	}
+
+	public List<EvaluationInfo> getEvaluationInfos() {
+		return evaluationInfos;
+	}
+
+	public void setEvaluationInfos(List<EvaluationInfo> evaluationInfos) {
+		this.evaluationInfos = evaluationInfos;
+	}
+
+	/**
+	 * 评测活动内容
+	 */
+	@Data
+	@NoArgsConstructor
+	@AllArgsConstructor
+	public static class EvaluationInfo implements Serializable {
+
+		@ApiModelProperty("主键 ")
+		private Long id;
+
+		@ApiModelProperty("评测难度 BEGINNER 入门级 ADVANCED 进阶级 PERFORMER 大师级 ")
+		private HardLevelEnum evaluationDifficulty;
+
+		private Date updateTime;
+		private Long updateBy;
+
+
+		public EvaluationInfo updateTime(Date updateTime) {
+			this.updateTime = updateTime;
+			return this;
+		}
+
+		public EvaluationInfo updateBy(Long updateBy) {
+			this.updateBy = updateBy;
+			return this;
+		}
+	}
 }

+ 12 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/entity/ActivityEvaluation.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.yonge.cooleshow.common.enums.ActivityResourceEnum;
+import com.yonge.cooleshow.common.enums.HardLevelEnum;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 
@@ -30,6 +31,10 @@ public class ActivityEvaluation implements Serializable {
     @TableField(value = "music_sheet_id_")
     private Long musicSheetId;
 
+    @ApiModelProperty("评测难度 BEGINNER 入门级 ADVANCED 进阶级 PERFORMER 大师级 ")
+    @TableField(value = "evaluation_difficulty_")
+    private HardLevelEnum evaluationDifficulty;
+
     @ApiModelProperty("资源类型 ")
     @TableField(value = "resource_type_")
     private ActivityResourceEnum resourceType;
@@ -91,4 +96,11 @@ public class ActivityEvaluation implements Serializable {
         this.createBy = createBy;
     }
 
+    public HardLevelEnum getEvaluationDifficulty() {
+        return evaluationDifficulty;
+    }
+
+    public void setEvaluationDifficulty(HardLevelEnum evaluationDifficulty) {
+        this.evaluationDifficulty = evaluationDifficulty;
+    }
 }

+ 8 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/ActivityEvaluationService.java

@@ -77,4 +77,12 @@ public interface ActivityEvaluationService extends IService<ActivityEvaluation>
 	 * @return IPage<ActivityTeacherWrapper>
 	 */
 	IPage<ActivityTeacherWrapper> activityTeacherByTimePageInfo(IPage<ActivityTeacherWrapper> page, ActivityTeacherQuery query);
+
+	/**
+	 * 批量更新评测曲目信息
+	 * @param user SysUser
+	 * @param info ActivityEvaluationDto
+	 * @return int
+	 */
+    int batchUpdateEvaluationInfo(SysUser user, ActivityEvaluationDto info);
 }

+ 23 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/ActivityEvaluationServiceImpl.java

@@ -1,5 +1,6 @@
 package com.yonge.cooleshow.biz.dal.service.impl;
 
+import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -333,4 +334,26 @@ public class ActivityEvaluationServiceImpl extends ServiceImpl<ActivityEvaluatio
         return page.setRecords(wrappers);
     }
 
+    /**
+     * 批量更新评测曲目信息
+     *
+     * @param user SysUser
+     * @param info ActivityEvaluationDto
+     * @return int
+     */
+    @Transactional
+    @Override
+    public int batchUpdateEvaluationInfo(SysUser user, ActivityEvaluationDto info) {
+
+        List<ActivityEvaluationDto.EvaluationInfo> evaluationInfos = info.getEvaluationInfos();
+
+        List<ActivityEvaluation> evaluations = JSON.parseArray(JSON.toJSONString(evaluationInfos),
+                ActivityEvaluation.class);
+
+        // 批量更新
+        activityEvaluationService.updateBatchById(evaluations, 30);
+
+        return evaluationInfos.size();
+    }
+
 }

+ 9 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/ActivityPlanServiceImpl.java

@@ -528,6 +528,15 @@ public class ActivityPlanServiceImpl extends ServiceImpl<ActivityPlanDao, Activi
             String evaluationDifficulty = baseMapper.selectActivityPlanEvaluation(activityPlanId);
             activityVo.setEvaluationDifficulty(evaluationDifficulty);
 
+            // 单曲排名
+            if (ActivityRankingMethodEnum.MUSIC_RANKING == activityPlan.getRankingMethod()) {
+
+                for (ActivityMusicVo item : activityVo.getActivityMusicVoList()) {
+
+                    item.setEvaluationDifficulty(evaluationDifficulty);
+                }
+            }
+
             // 计算评测活动声部最高分
             if (ActivityRankingMethodEnum.TOTAL_SCORE == activityPlan.getRankingMethod()) {