Browse Source

Merge branch 'dev_1_2_20220802'

liweifan 3 years ago
parent
commit
e5bd61301c

+ 2 - 2
cooleshow-user/user-admin/src/main/java/com/yonge/cooleshow/admin/controller/ActivityPlanController.java

@@ -58,12 +58,12 @@ public class ActivityPlanController extends BaseController {
      */
     @PostMapping("/submit")
     @ApiOperation(value = "新增或修改", notes = "传入activityPlan")
-    public HttpResponseResult submit(@Valid @RequestBody ActivityPlanDto activityPlan) {
+    public HttpResponseResult<ActivityPlan> submit(@Valid @RequestBody ActivityPlanDto activityPlan) {
         SysUser user = sysUserFeignService.queryUserInfo();
         if (user == null || null == user.getId()) {
             return failed(HttpStatus.FORBIDDEN, "请登录");
         }
-        return status(activityPlanService.submit(activityPlan, user));
+        return HttpResponseResult.succeed(activityPlanService.submit(activityPlan, user));
     }
 
     /**

+ 12 - 32
cooleshow-user/user-admin/src/main/java/com/yonge/cooleshow/admin/controller/ActivityRewardController.java

@@ -27,13 +27,22 @@ public class ActivityRewardController extends BaseController {
     private ActivityRewardService activityRewardService;
 
 	/**
-     * 查询单条
+     * 通过奖品id查询单条
      */
     @GetMapping("/detail/{id}")
     @ApiOperation(value = "详情", notes = "传入id")
     public HttpResponseResult<ActivityRewardVo> detail(@PathVariable("id") Long id) {
     	return succeed(activityRewardService.detail(id));
 	}
+
+	/**
+	 * 通过活动id查询单条
+	 */
+	@GetMapping("/detailByActivityId/{id}")
+	@ApiOperation(value = "详情", notes = "传入id")
+	public HttpResponseResult<ActivityRewardVo> detailByActivityId(@PathVariable("id") Long id) {
+		return succeed(activityRewardService.detailByActivityId(id));
+	}
     
     /**
      * 查询分页
@@ -44,43 +53,14 @@ public class ActivityRewardController extends BaseController {
 		IPage<ActivityRewardVo> pages = activityRewardService.selectPage(PageUtil.getPage(query), query);
         return succeed(PageUtil.pageInfo(pages));
 	}
-    
-    /**
-	 * 新增
-	 */
-	@PostMapping("/save")
-	@ApiOperation(value = "新增", notes = "传入activityReward")
-	public HttpResponseResult save(@Valid @RequestBody ActivityReward activityReward) {
-    	return status(activityRewardService.save(activityReward));
-	}
-    
-    /**
-	 * 修改
-	 */
-	@PostMapping("/update")
-	@ApiOperation(value = "修改", notes = "传入activityReward")
-	public HttpResponseResult update(@Valid @RequestBody ActivityReward activityReward) {
-        return status(activityRewardService.updateById(activityReward));
-	}
-    
+
     /**
 	 * 新增或修改
 	 */
     @PostMapping("/submit")
     @ApiOperation(value = "新增或修改", notes = "传入activityReward")
 	public HttpResponseResult submit(@Valid @RequestBody ActivityReward activityReward) {
-        return status(activityRewardService.saveOrUpdate(activityReward));
+        return status(activityRewardService.submit(activityReward));
     }
 
- 	/**
-	 * 删除
-	 */
-	@PostMapping("/remove")
-	@ApiOperation(value = "删除", notes = "传入ids")
-	public HttpResponseResult remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
-        if (StringUtil.isEmpty(ids)) {
-			return failed("参数不能为空");
-		}
-		return status(activityRewardService.removeByIds(StringUtil.toLongList(ids)));
-	}
 }

+ 2 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dao/ActivityRewardDao.java

@@ -18,6 +18,7 @@ public interface ActivityRewardDao extends BaseMapper<ActivityReward>{
      * @return: com.yonge.cooleshow.biz.dal.vo.ActivityRewardVo
 	 */
 	ActivityRewardVo detail(@Param("id") Long id);
+	ActivityRewardVo detailByActivityId(@Param("id") Long id);
 
 	/**
 	 * 分页查询
@@ -26,5 +27,5 @@ public interface ActivityRewardDao extends BaseMapper<ActivityReward>{
      * @return: com.yonge.cooleshow.biz.dal.vo.ActivityRewardVo
 	 */
 	List<ActivityRewardVo> selectPage(@Param("page") IPage page, @Param("param") ActivityRewardSearch activityReward);
-	
+
 }

+ 31 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/entity/ActivityReward.java

@@ -12,6 +12,9 @@ import java.util.Date;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import org.springframework.format.annotation.DateTimeFormat;
 
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+
 /**
  * 活动奖品表
  */
@@ -24,15 +27,19 @@ public class ActivityReward implements Serializable {
     private Long id;
     @ApiModelProperty("活动id ")
 	@TableField(value = "activity_id_")
+    @NotNull(message = "活动id不能为空")
     private Long activityId;
     @ApiModelProperty("奖品名称 ")
 	@TableField(value = "reward_name_")
+    @NotBlank(message = "奖品名称不能为空")
     private String rewardName;
     @ApiModelProperty("奖品描述 ")
 	@TableField(value = "reward_describe_")
+    @NotBlank(message = "奖品描述不能为空")
     private String rewardDescribe;
     @ApiModelProperty("奖品图片 ")
 	@TableField(value = "img_url_")
+    @NotBlank(message = "奖品图片不能为空")
     private String imgUrl;
     @ApiModelProperty("创建时间 ")
 	@TableField(value = "create_time_")
@@ -42,6 +49,14 @@ public class ActivityReward implements Serializable {
     @ApiModelProperty("创建人 ")
 	@TableField(value = "create_by_")
     private Long createBy;
+    @ApiModelProperty("更新时间 ")
+    @TableField(value = "update_time_")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
+    private Date updateTime;
+    @ApiModelProperty("更新人 ")
+    @TableField(value = "update_by_")
+    private Long updateBy;
 
 	public Long getId() {
         return id;
@@ -98,5 +113,20 @@ public class ActivityReward implements Serializable {
     public void setCreateBy(Long createBy) {
         this.createBy = createBy;
     }
-    
+
+    public Date getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(Date updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    public Long getUpdateBy() {
+        return updateBy;
+    }
+
+    public void setUpdateBy(Long updateBy) {
+        this.updateBy = updateBy;
+    }
 }

+ 1 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/ActivityPlanService.java

@@ -42,7 +42,7 @@ public interface ActivityPlanService extends IService<ActivityPlan>  {
 	 * @param user
 	 * @return
 	 */
-	Boolean submit(ActivityPlanDto activityPlan, SysUser user);
+	ActivityPlan submit(ActivityPlanDto activityPlan, SysUser user);
 
 	Boolean updateActivityState(Long activityId, Integer activityState, Long id);
 	/**

+ 10 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/ActivityRewardService.java

@@ -21,14 +21,22 @@ public interface ActivityRewardService extends IService<ActivityReward>  {
  	 * @date 2022-08-04
      */
 	ActivityRewardVo detail(Long id);
+	/**
+	 * 通过活动id查询详情
+	 * @author liweifan
+	 * @date 2022-08-04
+	 */
+	ActivityRewardVo detailByActivityId(Long id);
 
-    /**
+	/**
      * 分页查询
      * @author liweifan
  	 * @date 2022-08-04
      */
     IPage<ActivityRewardVo> selectPage(IPage<ActivityRewardVo> page, ActivityRewardSearch query);
 
+	Boolean submit(ActivityReward activityReward);
+
 	/**
 	 * 获取活动所有奖品
 	 *
@@ -36,4 +44,5 @@ public interface ActivityRewardService extends IService<ActivityReward>  {
 	 * @return
 	 */
     List<ActivityReward> getActivityReward(Long activityPlanId);
+
 }

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

@@ -89,10 +89,10 @@ public class ActivityPlanServiceImpl extends ServiceImpl<ActivityPlanDao, Activi
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public Boolean submit(ActivityPlanDto activityPlan, SysUser user) {
+    public ActivityPlan submit(ActivityPlanDto activityPlan, SysUser user) {
         //验证参数
         if (!validParam(activityPlan)) {
-            return false;
+            return null;
         }
 
         if (null == activityPlan.getId()) {
@@ -106,7 +106,7 @@ public class ActivityPlanServiceImpl extends ServiceImpl<ActivityPlanDao, Activi
             planEvaluation.setCreateBy(user.getId());
             planEvaluation.setUpdateBy(user.getId());
             activityPlanEvaluationDao.insert(planEvaluation);
-            return true;
+            return activityPlan;
         } else {
             ActivityPlan old = getById(activityPlan.getId());
             //启用状态,只能修改活动结束时间
@@ -114,10 +114,10 @@ public class ActivityPlanServiceImpl extends ServiceImpl<ActivityPlanDao, Activi
                 if (activityPlan.getActivityEnd().after(new Date())) {
                     old.setActivityEnd(activityPlan.getActivityEnd());
                     old.setUpdateBy(user.getId());
-                    updateById(activityPlan);
-                    return true;
+                    updateById(old);
+                    return old;
                 }
-                return false;
+                return null;
             } else {
                 activityPlan.setUpdateBy(user.getId());
                 updateById(activityPlan);
@@ -125,7 +125,7 @@ public class ActivityPlanServiceImpl extends ServiceImpl<ActivityPlanDao, Activi
                 ActivityPlanEvaluation planEvaluation = activityPlan.getPlanEvaluation();
                 planEvaluation.setUpdateBy(user.getId());
                 activityPlanEvaluationDao.updateById(planEvaluation);
-                return true;
+                return activityPlan;
             }
         }
     }
@@ -177,12 +177,18 @@ public class ActivityPlanServiceImpl extends ServiceImpl<ActivityPlanDao, Activi
         MusicActivityVo activityVo = new MusicActivityVo();
         BeanUtils.copyProperties(activityPlan, activityVo);
 
+        Long userId = null;
+        if (user != null && user.getId() != null) {
+            userId = user.getId();
+        }
+
+
         // 活动曲目
-        List<ActivityMusicVo> activityMusicVoList = activityEvaluationService.getActivityMusic(activityPlanId, user.getId());
+        List<ActivityMusicVo> activityMusicVoList = activityEvaluationService.getActivityMusic(activityPlanId, userId);
         activityVo.setActivityMusicVoList(activityMusicVoList);
 
         // 报名状态
-        activityVo.setJoin(activityRegistrationService.getRegistration(user.getId(), activityPlanId));
+        activityVo.setJoin(activityRegistrationService.getRegistration(userId, activityPlanId));
 
         // 活动奖品
         List<ActivityReward> activityRewardList = activityRewardService.getActivityReward(activityPlanId);

+ 48 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/ActivityRewardServiceImpl.java

@@ -1,7 +1,11 @@
 package com.yonge.cooleshow.biz.dal.service.impl;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.yonge.cooleshow.biz.dal.dao.ActivityPlanDao;
+import com.yonge.cooleshow.biz.dal.entity.ActivityPlan;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -10,7 +14,9 @@ import com.yonge.cooleshow.biz.dal.vo.ActivityRewardVo;
 import com.yonge.cooleshow.biz.dal.dto.search.ActivityRewardSearch;
 import com.yonge.cooleshow.biz.dal.dao.ActivityRewardDao;
 import com.yonge.cooleshow.biz.dal.service.ActivityRewardService;
+import org.springframework.transaction.annotation.Transactional;
 
+import javax.annotation.Resource;
 import java.util.List;
 
 
@@ -18,17 +24,58 @@ import java.util.List;
 public class ActivityRewardServiceImpl extends ServiceImpl<ActivityRewardDao, ActivityReward> implements ActivityRewardService {
     private final static Logger log = LoggerFactory.getLogger(ActivityRewardServiceImpl.class);
 
+    @Resource
+    private ActivityPlanDao activityPlanDao;
+
 	@Override
     public ActivityRewardVo detail(Long id) {
         return baseMapper.detail(id);
     }
-    
+
+    @Override
+    public ActivityRewardVo detailByActivityId(Long id) {
+        return baseMapper.detailByActivityId(id);
+    }
+
     @Override
     public IPage<ActivityRewardVo> selectPage(IPage<ActivityRewardVo> page, ActivityRewardSearch query){
         return page.setRecords(baseMapper.selectPage(page, query));
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
+    public Boolean submit(ActivityReward activityReward) {
+        if(null == activityReward.getActivityId()){
+            return createActivityReward(activityReward);
+        }else{
+            return updateActivityReward(activityReward);
+        }
+    }
+
+    private Boolean createActivityReward(ActivityReward activityReward) {
+        baseMapper.delete(Wrappers.<ActivityReward>lambdaQuery()
+                .eq(ActivityReward::getActivityId, activityReward.getActivityId())
+        );
+        baseMapper.insert(activityReward);
+        //更改活动状态
+        ActivityPlan activityPlan = new ActivityPlan();
+        activityPlan.setId(activityReward.getActivityId());
+        activityPlan.setDraftFlag(0);
+        activityPlanDao.updateById(activityPlan);
+        return true;
+    }
+
+    private Boolean updateActivityReward(ActivityReward activityReward) {
+        baseMapper.updateById(activityReward);
+        //更改活动状态
+        ActivityPlan activityPlan = new ActivityPlan();
+        activityPlan.setId(activityReward.getActivityId());
+        activityPlan.setDraftFlag(0);
+        activityPlanDao.updateById(activityPlan);
+        return true;
+    }
+
+    @Override
     public List<ActivityReward> getActivityReward(Long activityPlanId) {
 
         return this.lambdaQuery()

+ 11 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/vo/ActivityMusicVo.java

@@ -35,6 +35,9 @@ public class ActivityMusicVo {
     private double score;
 
 
+    @ApiModelProperty("最高分的用户id")
+    private Long userId;
+
     @ApiModelProperty("最高分用户头像")
     private String userAvatar;
 
@@ -44,6 +47,14 @@ public class ActivityMusicVo {
     @ApiModelProperty("最高分用户声部")
     private String userSubject;
 
+    public Long getUserId() {
+        return userId;
+    }
+
+    public void setUserId(Long userId) {
+        this.userId = userId;
+    }
+
     public Long getEvaluationId() {
         return evaluationId;
     }

+ 5 - 2
cooleshow-user/user-biz/src/main/resources/config/mybatis/ActivityEvaluationMapper.xml

@@ -52,7 +52,7 @@
 
     <select id="selectActivityMusic" resultType="com.yonge.cooleshow.biz.dal.vo.ActivityMusicVo">
 
-        select ms.id_ as musciSheetId
+        select ms.id_ as musicSheetId
         ,ms.music_sheet_name_ as musicSheetName
         ,s.name_ as musicSubject
         ,ae.id_ as evaluationId
@@ -63,8 +63,9 @@
         left join music_sheet ms on ms.id_ = ae.music_sheet_id_
         left join subject s on s.id_ = ms.music_subject_
         <where>
+            ms.del_flag_ = 0 and ms.state_ = 1
             <if test="activityPlanId != null">
-                ae.activity_id_ = #{activityPlanId}
+                and ae.activity_id_ = #{activityPlanId}
             </if>
         </where>
     </select>
@@ -75,6 +76,7 @@
         ,t.avatar_ as userAvatar
         ,s.name_ as userSubject
         ,t.evaluationId
+        ,t.userId
         from
         (select
             max(aem.score_) as score,
@@ -82,6 +84,7 @@
             aem.user_id_,
         su.username_,
         su.avatar_,
+        su.id_ as userId,
         aem.evaluation_id_ as evaluationId
 
         from  activity_evaluation_record aem

+ 13 - 1
cooleshow-user/user-biz/src/main/resources/config/mybatis/ActivityRewardMapper.xml

@@ -9,6 +9,8 @@
 	        <result column="img_url_" property="imgUrl" />
 	        <result column="create_time_" property="createTime" />
 	        <result column="create_by_" property="createBy" />
+            <result column="update_time_" property="updateTime" />
+            <result column="update_by_" property="updateBy" />
 		</resultMap>  
     
     <!-- 表字段 -->
@@ -20,6 +22,8 @@
         , t.img_url_ as imgUrl
         , t.create_time_ as createTime
         , t.create_by_ as createBy
+        , t.update_time_ as updateTime
+        , t.update_by_ as updateBy
         </sql> 
     
     <select id="detail" resultType="com.yonge.cooleshow.biz.dal.vo.ActivityRewardVo">
@@ -28,7 +32,15 @@
         FROM activity_reward t
         where t.id_ = #{id}
     </select>
-    
+
+    <select id="detailByActivityId" resultType="com.yonge.cooleshow.biz.dal.vo.ActivityRewardVo">
+        SELECT
+            <include refid="baseColumns"/>
+        FROM activity_reward t
+        where t.activity_id_ = #{id}
+    </select>
+
+
     <select id="selectPage" resultType="com.yonge.cooleshow.biz.dal.vo.ActivityRewardVo">
 		SELECT         
         	<include refid="baseColumns" />

+ 0 - 14
cooleshow-user/user-student/src/main/java/com/yonge/cooleshow/student/controller/StudentActivityController.java

@@ -31,20 +31,6 @@ public class StudentActivityController extends BaseController {
     private ActivityPlanService activityPlanService;
 
 
-    @ApiOperation(value = "活动信息", notes = "活动id")
-    @PostMapping(value = "/info/{id}")
-    public HttpResponseResult<MusicActivityVo> getDetail(@PathVariable Long id) {
-        SysUser user = sysUserFeignService.queryUserInfo();
-        if (user == null || null == user.getId()) {
-            return failed(HttpStatus.FORBIDDEN, "请登录");
-        }
-
-        MusicActivityVo activityVo = activityPlanService.getActivityInfo(id, user);
-
-        return succeed(activityVo);
-    }
-
-
     @ApiOperation(value = "评测活动参与项目", notes = "评测项目id")
     @PostMapping(value = "/evaluation/{evaluationId}")
     public HttpResponseResult<Boolean> joinEvaluation(@PathVariable Long evaluationId) {

+ 23 - 4
cooleshow-user/user-student/src/main/java/com/yonge/cooleshow/student/controller/open/OpenClient.java

@@ -1,7 +1,11 @@
 package com.yonge.cooleshow.student.controller.open;
 
+import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
+import com.yonge.cooleshow.auth.api.entity.SysUser;
+import com.yonge.cooleshow.biz.dal.service.ActivityPlanService;
 import com.yonge.cooleshow.biz.dal.service.StudentService;
 import com.yonge.cooleshow.biz.dal.service.TeacherService;
+import com.yonge.cooleshow.biz.dal.vo.MusicActivityVo;
 import com.yonge.cooleshow.biz.dal.vo.TeacherVo;
 import com.yonge.cooleshow.common.controller.BaseController;
 import com.yonge.cooleshow.common.entity.HttpResponseResult;
@@ -9,10 +13,7 @@ import com.yonge.toolset.base.util.StringUtil;
 import com.yonge.toolset.utils.string.ValueUtil;
 import io.swagger.annotations.*;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import java.util.Map;
 
@@ -23,6 +24,8 @@ import java.util.Map;
 public class OpenClient extends BaseController {
     @Autowired
     private TeacherService teacherService;
+    @Autowired
+    private SysUserFeignService sysUserFeignService;
 
     @Autowired
     private StudentService studentService;
@@ -55,4 +58,20 @@ public class OpenClient extends BaseController {
         }
         return studentService.bindTeacher(phone, userId, isUpdate);
     }
+
+
+
+    @Autowired
+    private ActivityPlanService activityPlanService;
+
+
+    @ApiOperation(value = "活动信息", notes = "活动id")
+    @PostMapping(value = "/activity/info/{id}")
+    public HttpResponseResult<MusicActivityVo> getDetail(@PathVariable Long id) {
+        SysUser user = sysUserFeignService.queryUserInfo();
+
+        MusicActivityVo activityVo = activityPlanService.getActivityInfo(id, user);
+
+        return succeed(activityVo);
+    }
 }